Topic:   Starship Troopers   (Read 16211 times)


0 Members and 4 Guests are viewing this topic.

bellybot1


  • GMG Newbie

  • *


  • Posts: 22

  • I love YaBB 1G - SP1!
Starship Troopers
« on: March 22, 2009, 02:02:11 AM »
Now with a tiny little bit of experience under my belt i have decided to embark upon a bigger adventure. This game is a mix between an RPG and a shooter. The finished product will hopefully be you as a trooper are attacked on board your ship by aliens and you have to go through the rooms and kill them all with your gun. The next bit is you attacking their ship and leading up to you attacking their main boss where you win the game. I have started off looking at how the fights will work and have decided on what i think is a good answer. Because you have a gun when you click the mouse the gun nozzle flashes, if your mouse was over an enemy when you click it takes some health off them. The aliens on the other hand chase you and when they come in contact with you start taking health off. To make it fair the aliens will move faster than you. I've already come up with a problem, how do i make it so if the mouse clicks on the alien it runs the code
Code: [Select]
KILLSPRITE 3
.

Thanks in advance.

P.S. IF you don't know the answer to this you may know how to make the alien walk towards you.

bellybot1


  • GMG Newbie

  • *


  • Posts: 22

  • I love YaBB 1G - SP1!
Re: Starship Troopers
« Reply #1 on: March 22, 2009, 02:12:57 AM »
OK Dont worry about the shooting i've solved it by going
Code: [Select]
IF Mouse Down = SPRITEVALID(2) THEN
KILLSPRITE 2
END IF
So now im working on the alien attacking me.

Thanks

bellybot1


  • GMG Newbie

  • *


  • Posts: 22

  • I love YaBB 1G - SP1!
Re: Starship Troopers
« Reply #2 on: March 22, 2009, 02:22:02 AM »
woops sorry just realised that that works if i click anywhere on the board.
So still working on that.

Teruri


  • GMG-er

  • **


  • Posts: 167

  • This personal text couldn\'t be worse
Re: Starship Troopers
« Reply #3 on: March 22, 2009, 07:01:56 AM »
In the mousedown code:

Code: [Select]
FOR sprite = 1 to 5
   IF mousex > spritex(sprite) then
      IF mousex < spritex(sprite) + spritewidth(sprite) then
         IF mousey > spritey(sprite) then
            IF mousey < spritey(sprite) + spriteheight(sprite) then
               IF spritevalid(sprite) = true then
                  KILLSPRITE(SPRITE)
               END IF
               EXIT
            END IF
         END IF
      END IF
   END IF
NEXT

This checks if you click down on a sprite with numbers between 1 and 5 (those included). Chage the numbers on the first line to your situation. If you just have one enemy, you can remove the first (for next...) and the last line (next).
Max 500; characters remaining: 466

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: Starship Troopers
« Reply #4 on: March 22, 2009, 10:40:47 AM »
if spritetouchingxy(3, mousex, mousey)=1 then
if spritevalid(3)=1 then
killsprite 3
end if
end if

Teruri


  • GMG-er

  • **


  • Posts: 167

  • This personal text couldn\'t be worse
Re: Starship Troopers
« Reply #5 on: March 22, 2009, 11:17:34 AM »
That's way shorter than my method o__O Didn't know you could do that too, all that time I did it the hard way.
Max 500; characters remaining: 466

Redd


  • GMG-er

  • **


  • Posts: 118

  • Silent, but very, very deadly.
Re: Starship Troopers
« Reply #6 on: March 22, 2009, 12:57:16 PM »
Quote
if spritetouchingxy(3, mousex, mousey)=1 then
if spritevalid(3)=1 then
killsprite 3
end if
end if
That method is extremely buggy though. Teruri's version is safer. :/

At least on my end SC ignores half the sprite. >_>

bellybot1


  • GMG Newbie

  • *


  • Posts: 22

  • I love YaBB 1G - SP1!
Re: Starship Troopers
« Reply #7 on: March 22, 2009, 01:32:52 PM »
cool thanks teruri. I think the problem i had was i kept forgetting that when your in the mouse down section everything always happens when the mouse goes down so you don't have to write mousedown. Ill probably start working on the sprites now and then focus on the alien attacking us. Anyhelp is appreciated.

Thanks

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: Starship Troopers
« Reply #8 on: March 22, 2009, 04:16:55 PM »
Quote
That method is extremely buggy though. Teruri's version is safer. :/

At least on my end SC ignores half the sprite. >_>
yea, it depends on the size of the sprite