Powerup Problem

Non-platform specific questions.

Powerup Problem

Postby BloodRedDragon » Sat Nov 22, 2008 4:22 pm

Hi peeps. I'm making a game in which you can collect powerups to shoot at the enemy. I'm trying to find out how to script the action when a player picks up the power up and he is equipped with machine gun ammo and can shoot a limited amount of bullets.

Ive tried this but i dont know how to correct it:

Collision with powerup icon:
machinefireP1 = 50;

Key Down: (This is what i press to fire the machine gun)
if(machinefireP1 =>0);
CreateActor("ball", "ball", "(none)", "(none)", 0, 0, false);
machinefireP1 = machinefireP1 -1;

Pleez help
Current projects:
Techno-Tank Arena: on hold
Techno-Tank SuperPortal (working title): 0.1%
Bowels of Galaxies: 35% (was a bit too optimistic)
User avatar
BloodRedDragon
 
Posts: 123
Joined: Tue Jan 29, 2008 10:07 pm
Location: The Underworld
Score: 5 Give a positive score

Re: Powerup Problem

Postby skydereign » Sat Nov 22, 2008 8:08 pm

This may not be what you meant, but you it should be: if(machinefireP1 >=0);
C does not take =>, if you want greater or equal to, it must be the other way.
I would set it just to >, because you don't want to fire when you have no ammo. Also, I believe you don't want to have the bullets fire all at the same time, so you should create a timer instead of create machine gun bullet. And add a timer event to create the bullet. This would slow the machine gun shot, and make it adjustable.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Powerup Problem

Postby Killagram » Sat Nov 22, 2008 10:56 pm

While you're at it, try this:

Make all powerups only one actor. Give him an animation for each type of powerup.
Then on collision, switch the ANIMINDEX of the powerup actor.
i.e.
Collision with powerup:
Code: Select all
switch(collide.animindex)
{
case 0:
//powerup code here
break;
case 1:
//powerup code here
break;
}


The animindex corresponds to the order of the animations in the list of animations in actor control.

Now as you place powerups in editor mode, you can set the animation in actor control to the proper type and it will be that type in game mode. :D
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
-Brian W. Kernighan
User avatar
Killagram
 
Posts: 31
Joined: Sun Aug 10, 2008 8:49 pm
Score: 5 Give a positive score

Re: Powerup Problem

Postby BloodRedDragon » Fri Jan 09, 2009 8:49 pm

Cheers guyz. i feel a bit stupid now putting => instead of >=.
BTW i have like 0 points and i've been on this forum for a year. Nobody gives me any points. Should I make more posts?
Current projects:
Techno-Tank Arena: on hold
Techno-Tank SuperPortal (working title): 0.1%
Bowels of Galaxies: 35% (was a bit too optimistic)
User avatar
BloodRedDragon
 
Posts: 123
Joined: Tue Jan 29, 2008 10:07 pm
Location: The Underworld
Score: 5 Give a positive score

Re: Powerup Problem

Postby mrgame » Fri Jan 09, 2009 10:59 pm

you get points for helping people not how long ya been here :). look at me. i never use to use the forum much for posting. and ive been here along time :) only just really started posting here so i will start helping peoples but i have barly any points at the moment.
mrgame
 
Posts: 118
Joined: Sun Oct 21, 2007 8:09 pm
Location: my computer
Score: 3 Give a positive score

Re: Powerup Problem

Postby BlarghNRawr » Sat Jan 10, 2009 5:37 am

dont know how i got my points lawl :P
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron