Topic:   moving sprites   (Read 38653 times)


0 Members and 5 Guests are viewing this topic.

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: moving sprites
« Reply #15 on: July 11, 2008, 06:11:54 PM »
I'm trying to accomplish a sprite to appear and move on its own.
This part of the code is for the player sprite to aim on its own (it currently works)
IF MouseVert < 110 THEN
SPRITE 2 50 150 up.jpg
END IF
IF MouseVert > 220 THEN
SPRITE 2 50 150 down.jpg
END IF
IF MouseVert > 119 THEN
 IF MouseVert < 219 THEN
SPRITE 2 50 150 forward.jpg
END IF

Yes I am still interested in TNT, I just want to finish this code before I go more into TNT and help you guys on the project.

oh and it doesn't say I need an END IF (usually it tells you when you miss that)
« Last Edit: July 11, 2008, 06:13:11 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: moving sprites
« Reply #16 on: July 11, 2008, 06:23:03 PM »
No, it only alerts you when you have too much END IFs, as then you'd be trying to end a condition that doesn't exist.

Also guys, you should really tab your code. It makes it so much easier to read and therefor find gliches.
I survived the spammage of 2007

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: moving sprites
« Reply #17 on: July 11, 2008, 08:44:38 PM »
It still doesn't work...  :'( :'( :'( :'( Well back to HTML for a while... *slumps away
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: moving sprites
« Reply #18 on: July 12, 2008, 02:47:47 AM »
That's really, really weird. If you wanna send me the file and mark the card that's having the problem I can take a look at it.
I survived the spammage of 2007

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: moving sprites
« Reply #19 on: July 12, 2008, 08:01:52 AM »
Is this what you're trying to do? (I haven't tested this)


Code: [Select]
Y = RANDOM 280 215 160 90  
X = 630
kills = 0
enemys = 0
X1 = X + 60
Y1 = Y + 75


ON TIMER 1
  event = event + 1

  SPRITE 1 169 4 barricade.gif
  IF MouseVert < 110 THEN
    SPRITE 2 50 150 up.jpg
  END IF
  IF MouseVert > 220 THEN
    SPRITE 2 50 150 down.jpg
  END IF
  IF MouseVert > 119 THEN
    IF MouseVert < 219 THEN
      SPRITE 2 50 150 forward.jpg
    END IF
  END IF
 
  IF event = 5 THEN
    X = X + 10
    SPRITE 3 X Y enemy.jpg
    SETAREA 1 X Y X1 Y1
  END IF

  IF event = 200 THEN
    enemys = enemys + 1
    X = 630
    SPRITE 3 X Y enemy.jpg
    SETAREA 1 X Y X1 Y1
    event = 0
  END IF

END TIMER
« Last Edit: July 12, 2008, 08:03:48 AM by AlStaffieri »

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: moving sprites
« Reply #20 on: July 12, 2008, 09:28:52 AM »
Here you go silver
http://www.mediafire.com/?1zxm8tgn9nw
I put comments so you know what im trying to do

its card 2
« Last Edit: July 12, 2008, 09:43:16 AM 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: moving sprites
« Reply #21 on: July 12, 2008, 10:32:03 AM »
I'll take a look at it now.
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: moving sprites
« Reply #22 on: July 12, 2008, 11:19:41 AM »
Here we are: http://www.mediafire.com/?2mnw7x3fyfa

I've tinkered with it enough to get a rough working version, but it's a bit slow due to the aiming script. I did away with the click area, as it wouldn't work for me. (and to be honest, I think click areas are dodgy at best. Nothing like a good old SpriteClicked test instead! ;) )

Code: [Select]
X = 630
Y = RANDOM 280 215 160 90
kills = 0
enemys = 0
SPRITE 1 169 4 barricade.gif
SPRITE 3 X Y enemy.jpg

'------------------------------------------------------------------------------------------------

ON TIMER 1
 Â event1 = event1 + 1

 Â IF MouseVert < 110 THEN SPRITE 2 50 150 up.jpg
 Â IF MouseVert > 220 THEN SPRITE 2 50 150 down.jpg
 Â IF MouseVert > 119 THEN
 Â   IF MouseVert < 219 THEN SPRITE 2 50 150 forward.jpg
 Â END IF

 Â IF event1 = 2 THEN
 Â   event1 = 0
 Â   X = X - 15
 Â   SPRITE 3 X Y
 Â END IF

 Â EnemyReachWall = SPRITECOLLIDE 1 3
 Â IF EnemyReachWall = 1 THEN
 Â   enemys = enemys + 1
 Â   X = 630
 Â   Y = RANDOM 280 215 160 90
 Â   SPRITE 3 X Y
 Â END IF
END TIMER

'------------------------------------------------------------------------------------------------

ON MOUSEDOWN
 Â IF SpriteClicked = 3 THEN
 Â   MOVIE 0 0 "put dying sounds here"
 Â   kills = kills + 1
 Â   X = 630
 Â   Y = RANDOM 280 215 160 90
 Â   SPRITE 3 X Y
 Â END IF
END MOUSEDOWN

Hope it helps anyway. :)
« Last Edit: July 12, 2008, 11:24:17 AM by Silverwind »
I survived the spammage of 2007

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: moving sprites
« Reply #23 on: July 12, 2008, 11:36:15 AM »
Wow, it worked great! just a little more code and should be ready! Probably by tomorrow.

THANKS!!  ;D ;D ;D ;D ;D ;D
« Last Edit: July 12, 2008, 11:36:45 AM by Gnome_Again »
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: moving sprites
« Reply #24 on: July 12, 2008, 11:40:10 AM »
Wow. You had almost the same thing I had. Yours was a bit more finished. Here's what I came up with just for show.

Code: [Select]

Y = RANDOM 280 215 160 90  
X = 630
kills = 0
enemys = 0
X1 = X + 30
Y1 = Y + 75
SPRITE 1 169 4 barricade.gif


ON TIMER 1
  event = event + 1
 
  IF MouseVert < 110 THEN
    SPRITE -2 50 150 up.jpg
  END IF
  IF MouseVert > 220 THEN
    SPRITE -2 50 150 down.jpg
  END IF
  IF MouseVert > 119 THEN
    IF MouseVert < 219 THEN
      SPRITE -2 50 150 forward.jpg
    END IF
  END IF
 
    X = X - 15
    X1 = X + 50
    SPRITE 3 X Y enemy.jpg
 
  IF event = 20 THEN
    enemys = enemys + 1
    X = 630
    SPRITE 3 X Y enemy.jpg
    event = 0
    Y = RANDOM 280 215 160 90
    Y1 = Y + 75
    X1 = X + 50
  END IF
 
bool = SPRITECOLLIDE 1 3
END TIMER


ON MOUSEDOWN
'if you shoot and miss it plays a gun sound
  MOVIE "put gun sounds here"
  ' if you click a sprite then you hit him (don't need click areas)
  IF spriteClicked = 3 THEN
    MOVIE "put dying sounds here"
    Kills = Kills + 1
  END IF
END MOUSEDOWN


Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: moving sprites
« Reply #25 on: July 12, 2008, 11:43:15 AM »
Yours worked too Al, thanks for your help everybody!


This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: moving sprites
« Reply #26 on: July 12, 2008, 12:09:00 PM »
I think i get what I did wrong

I wrote
X + 5
which makes it go backwards

 :-[
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.