Topic:   Hmm.. Code trouble   (Read 32495 times)


0 Members and 3 Guests are viewing this topic.

Swamp7hing


  • GMG-er

  • **


  • Posts: 751

  • I come from the swamps.
Hmm.. Code trouble
« on: December 10, 2008, 09:08:26 PM »
It seems quite simple - I'm trying to get a sprite to move forward after each timer round has gone past.

Code: [Select]
MOVIE 0 0 Airtight Box.MP3

s1x = 5
s2x = 5
s3x = 5
s4x = 5

SPRITE 1 s1x 80 UpArrow
SPRITE 2 s2x 140 RightArrow
SPRITE 3 s3x 205 DownArrow
SPRITE 4 s4x 265 LeftArrow

ON TIMER 10
s1x = s1x + 2
s2x = s2x + 2
s3x = s3x + 2
s4x = s4x + 2

SPRITE 1 s1x 80 UpArrow
SPRITE 2 s2x 140 RightArrow
SPRITE 3 s3x 205 DownArrow
SPRITE 4 s4x 265 LeftArrow
END TIMER


Why does this not work?

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: Hmm.. Code trouble
« Reply #1 on: December 10, 2008, 09:22:34 PM »
Do the Files names of LEFTARROW RIGHTARROW UPARROW DOWNARROW have file extensions? like LEFTARROW.jpg? that could be it.


arrows eh? making GM DDR?
« Last Edit: December 10, 2008, 09:43:29 PM by Gnome_Again »
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Hmm.. Code trouble
« Reply #2 on: December 11, 2008, 02:25:44 AM »
As Gnome suggested. By the way, you can make your sprites load a little faster by leaving out the filename once they've been loaded the first time. (when GM sees the filename in a sprite command, it assigns the image to the sprite. But if you've already assigned the image to the sprite, you don't need to do it again. :) )

Also, when loading sprites in bulk, by giving them all a negative value except for the last one loaded, they'll load slightly faster. Take a looksy:

Code: [Select]
MOVIE 0 0 Airtight Box.MP3

s1y = 80
s2y = 140
s3y = 205
s4y = 265
s1x = 5
s2x = 5
s3x = 5
s4x = 5

SPRITE -1 s1x s1y UpArrow.gif
SPRITE -2 s2x s2y RightArrow.gif
SPRITE -3 s3x s3y DownArrow.gif
SPRITE 4 s4x s4y LeftArrow.gif

ON TIMER 10
 Â s1x = s1x + 2
 Â s2x = s2x + 2
 Â s3x = s3x + 2
 Â s4x = s4x + 2

 Â SPRITE -1 s1x s1y
 Â SPRITE -2 s2x s2y
 Â SPRITE -3 s3x s3y
 Â SPRITE 4 s4x s4y
END TIMER
I've also mapped the Y locations to variables in case you decide to change them later. (less code to alter) I usually do the same with sprite names too, but there's no need if you're not gonna be changing the picture.
« Last Edit: December 11, 2008, 02:34:05 AM by Silverwind »
I survived the spammage of 2007

Swamp7hing


  • GMG-er

  • **


  • Posts: 751

  • I come from the swamps.
Re: Hmm.. Code trouble
« Reply #3 on: December 11, 2008, 07:52:41 AM »
Awesome, thanks guys. The files have no visible file extensions, but I'll add them in. Test later today, I'm off to school now.

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: Hmm.. Code trouble
« Reply #4 on: December 11, 2008, 08:31:10 AM »
Quote
Awesome, thanks guys. The files have no visible file extensions, but I'll add them in. Test later today, I'm off to school now.

In the Finder, select the file and do a Get Info. That will show you what the file extension is if there is any.