Topic:   Tanks   (Read 18221 times)


0 Members and 2 Guests are viewing this topic.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Tanks
« 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??
« Last Edit: April 24, 2010, 04:17:23 PM by Connors »
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

GMG Mike


  • Administrator

  • GMG-er

  • *****

  • no avatar

  • Posts: 536
    • mikerichardson.name
Re: Tanks
« Reply #1 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.
« Last Edit: April 24, 2010, 07:03:33 PM by Mike_Richardson »

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: Tanks
« Reply #2 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.
« Last Edit: April 25, 2010, 12:12:15 AM by Connors »
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

GMG Mike


  • Administrator

  • GMG-er

  • *****

  • no avatar

  • Posts: 536
    • mikerichardson.name
Re: Tanks
« Reply #3 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.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: Tanks
« Reply #4 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.
« Last Edit: April 25, 2010, 04:12:55 PM by Connors »
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/