Topic:   moving sprites   (Read 38575 times)


0 Members and 2 Guests are viewing this topic.

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
moving sprites
« on: July 03, 2008, 01:03:52 PM »
Hey guys this is my last day until I leave for a week long camp, but I want to get this fixed

here is a snippet of my defense code.
Y = RANDOM 280 215 160 90
X = 630
kills = 0
enemys = 0
X1 = X + 60
Y1 = Y + 75
ON TIMER 200
enemys = enemys + 1
X = 630
SPRITE 3 X Y enemy.jpg
SETAREA 1 X Y [X1 Y1]
END TIMER

ON TIMER 5
X = X + 10
END TIMER

I need the enemy to appear and move in a straight line, but the sprite won't even appear, let alone move. PLEASE HELP!
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 #1 on: July 03, 2008, 01:05:29 PM »
I'll study it. :) Is this in a repeat loop or anything?
I survived the spammage of 2007

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: moving sprites
« Reply #2 on: July 03, 2008, 01:10:10 PM »
Ok, the problem is that you're using two timers which interrupt each other. Here's the fixed code:

Y = RANDOM 280 215 160 90
X = 630
kills = 0
enemys = 0
X1 = X + 60
Y1 = Y + 75

ON TIMER 1
 Â event1 = event1 + 1
 Â event2 = event2 + 1

 Â IF event1 = 200 THEN
 Â   event1 = 0
 Â   enemys = enemys + 1
 Â   X = 630
 Â   SPRITE 3 X Y enemy.jpg
 Â   SETAREA 1 X Y [X1 Y1]
 Â END IF
 
 Â IF event2 = 5 THEN
 Â   event2 = 0
 Â   X = X + 10
 Â END IF
END TIMER
« Last Edit: July 10, 2008, 01:58:39 PM by Silverwind »
I survived the spammage of 2007

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: moving sprites
« Reply #3 on: July 03, 2008, 01:19:00 PM »
almost worked, but it says "X = 630" has a syntax error. I don't know why, since everything is spaced properly. is it a glitch?
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 #4 on: July 03, 2008, 02:55:57 PM »
There's probably an invisible character in there that doesn't show up. Just delete that one line and retype it.

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: moving sprites
« Reply #5 on: July 10, 2008, 09:50:07 AM »
the sprite still isn't showing up, this is getting really annoying, it's spelled correctly and everything.  >:( >:( >:( >:( >:( >:( >:( >:(

Plus I need to finish this before I get to the bulk of the code (it's already some of the biggest code I've made)
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: moving sprites
« Reply #6 on: July 10, 2008, 10:19:46 AM »
that because the timer keeps on starting over.
the code keeps on looping around and the timer restarts.

Y = RANDOM 280 215 160 90  
X = 630  
kills = 0  
enemys = 0  
X1 = X + 60  
Y1 = Y + 75

IF z = 0 THEN
z = 1
ON TIMER 1
z = 0
  event1 = event1 + 1  
  event2 = event2 + 21
 
  IF event1 = 200 THEN
    event1 = 0
    enemys = enemys + 1  
    X = 630  
    SPRITE 3 X Y enemy.jpg  
    SETAREA 1 X Y [X1 Y1]  
  END IF
  
  IF event2 = 5 THEN
    event2 = 0
    X = X + 10
  END IF  
END TIMER
 That should work
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: moving sprites
« Reply #7 on: July 10, 2008, 02:05:55 PM »
I'm not sure if I understand the problem, but make sure Loop Script isn't activated on the card with this code, otherwise the timer will keep reseting itself. (though with a time trigger of 1 I'm not sure if it would make a difference)

I noticed a mistake in the code earlier, where I'd mistyped "event2 = event2 + 1" as "event2 = event2 + 21". That might be the problem. Make sure the "event" variables only increase by 1.
« Last Edit: July 10, 2008, 02:07:22 PM by Silverwind »
I survived the spammage of 2007

Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: moving sprites
« Reply #8 on: July 10, 2008, 03:19:24 PM »
I thought the 21 was weird but I dismissed it thinking it had some greater purpose.
« Last Edit: July 10, 2008, 03:20:53 PM by Tireas_Dragon »
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: moving sprites
« Reply #9 on: July 11, 2008, 04:23:49 PM »
Well it has to have a loop script on it, because it has the aiming loop on it.  :-[

EDIT: I fixed the typo but still no dice. Is there any other way to go about this?  ???
« Last Edit: July 11, 2008, 04:29:02 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 #10 on: July 11, 2008, 04:35:50 PM »
Just put the aiming code (and any other code you need to loop) inside the timer block, as the timer is set to maximum speed which is about the same as loop speed.
I survived the spammage of 2007

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: moving sprites
« Reply #11 on: July 11, 2008, 04:50:56 PM »
Still nothing, enemy.jpg is spelled correctly, is there anything completely obvious that I'm missing, because that seems to happen to me a lot... :(
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: moving sprites
« Reply #12 on: July 11, 2008, 05:02:51 PM »
is it sprite 11-20 in compiled mode?
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: moving sprites
« Reply #13 on: July 11, 2008, 05:05:42 PM »
probably not since there is only 3 sprites at a time.

here is my code so far
Y = RANDOM 280 215 160 90  
X = 630
kills = 0
enemys = 0
X1 = X + 60
Y1 = Y + 75


ON TIMER 1
 Â event1 = event1 + 1
 Â event2 = event2 + 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

 Â IF event1 = 200 THEN
 Â IF z = 0 THEN
 Â     event1 = 0
 Â     enemys = enemys + 1
 Â     X = 630
 Â     SPRITE 3 X Y enemy.jpg
 Â     SETAREA 1 X Y [X1 Y1]
z = 1
 END IF

IF event1 = 200 THEN
IF z = 1 THEN
event1 = 0
END  IF

 Â  IF event2 = 5 THEN
 Â  IF z = 1 THEN
 Â     event2 = 0
 Â     X = X + 10
 Â     END IF
END TIMER
IF event2 = 5 THEN
IF z = 0 THEN
event2 = 0
END IF
not the whole thing but its my sprite moving script.
« Last Edit: July 11, 2008, 05:09:12 PM by Gnome_Again »
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: moving sprites
« Reply #14 on: July 11, 2008, 05:34:59 PM »
What exactly are you trying to accomplish?

Also, I'm not too good at Gm, but aren't you missing a few End Ifs?

Just guessing, but shouldn't it be this?:

Quote
Y = RANDOM 280 215 160 90  
X = 630
kills = 0
enemys = 0
X1 = X + 60
Y1 = Y + 75
 
 
ON TIMER 1
event1 = event1 + 1
event2 = event2 + 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 event1 = 200 THEN
IF z = 0 THEN
event1 = 0
enemys = enemys + 1
X = 630
SPRITE 3 X Y enemy.jpg
SETAREA 1 X Y [X1 Y1]
z = 1
END IF  
END IF
 
IF event1 = 200 THEN
IF z = 1 THEN
event1 = 0
END  IF
END IF

IF event2 = 5 THEN
IF z = 1 THEN
event2 = 0
X = X + 10
END IF
END IF
END TIMER
IF event2 = 5 THEN
IF z = 0 THEN
event2 = 0
END IF
END IF

Also, are you still interested in Tnt?


-Gandolf
« Last Edit: July 11, 2008, 05:37:35 PM by Gandolf »