Game Maker's Garage Forum

Game Creation => SilverCreator => Topic started by: Connors on April 24, 2010, 04:14:23 PM

Title: Tanks
Post by: Connors on April 24, 2010, 04:14:23 PM
I will use this topic to post the questions that keep coming up about my latest project I guess....
SO here's the biggest problem:

Code: [Select]
ON TIMER 1
  
   LET grav=grav-weight
   LET fall=fall-grav
  
   IF speed > 3000 then
      LET speed=speed* 0.985  //add a speed limit
   END IF
  
   IF SPRITEVALID (3) = true THEN
      
      PUSHSPRITE (3), (speed/150), (fall/150)
      
      IF SPRITESTOUCHING (2,3) = true THEN
         HIT
         LET HP2 = HP2 - dmg
      END IF
      
      IF SPRITESTOUCHING (3,1) = true THEN
         HIT
         LET HP1 = HP1 - dmg
      END IF
      
      IF spritey(3) > 400 THEN
         HIT
         STOPTIMER
      END IF
      
   END IF
  
END TIMER

It keeps saying invalid sprite number where I put
IF SPRITEVALID(3) = true THEN
Which really bothers me because why is it executing the code if I already checked whether sprite 3 is there??
Title: Re: Tanks
Post by: GMG Mike on April 24, 2010, 06:53:35 PM
You are not supposed to have any space between the name of the function and the parameter list. The only reason it works is because some people did it this way in the past and their projects broke with the new system.

Incorrect: SPRITEVALID (3)
Correct: SPRITEVALID(3)

Also, only SilverCreator v2.0b1 is supported. If you are using an older version, I can not help you.

You may be experiencing a particular bug in your code as well. What happens is that an error inside of the HIT method is shown as if it occurred wherever you called the HIT method. The bug is fixed in v2.0b2 which will be released soon.
Title: Re: Tanks
Post by: Connors on April 25, 2010, 12:05:37 AM
Thanks, I'm glad thats cleared up because some parameters were acting odd. XD Also, I am using 2.0b1 right now.

EDIT: I still can figure out why it's saying invalid sprite number though.
Title: Re: Tanks
Post by: GMG Mike on April 25, 2010, 12:55:15 AM
Quote
Thanks, I'm glad thats cleared up because some parameters were acting odd. XD Also, I am using 2.0b1 right now.

EDIT: I still can figure out why it's saying invalid sprite number though.


Try looking in the HIT method. Like I said it's a bug in v2.0b1 that is fixed in v2.0b2.
Title: Re: Tanks
Post by: Connors on April 25, 2010, 04:10:56 PM
I finally caught the problem:
HIT contains KILLSPRITE 3 so even if I changed it to say HIT and then STOPTIMER it checks the rest of the loop (after clearing sprite 3) before stopping and has a glitch.