CHARGE ATTACK

You must understand the Game Editor concepts, before post here.

CHARGE ATTACK

Postby toshiro » Sun Nov 25, 2007 6:20 am

Im trying to give my actor two attacks with one button. First he has a regular shooting attack. When you press z he shoots a bullet at you. So basically at the Z button keydown event he creates the actor (bullet) which flies across the screen when its created. Now what i want to do is make it so that after you hold down Z For a specific time it changes the attack to a different actor . for example (press Z once = fire one bullet) (hold Z down for 5 seconds = fire machine gun).So i tried making a variable called (charge_count) and set its start up number to 0.Then i made it so that when Z is pressed the number goes up by 1 and enabled repeat. Therefore when you press and hold Z the charge_count goes up by one and then keeps on increasing until the keyup event.At the keyup event the player will check if the charge_count is above 29 and if so then it would change the type of attack.To me all of my methods seem practical and should work, but they dont. When you hold and realse the Z button it does change the attack, but it does the same thing when you simply press it and it also creates the bullet at the same time; firing two attacks instead of one.I've tried everything i can think of so i guess my coding is off, if you can please help.

heres my coding

[PLAYER]
{DRAW ACTOR}
Code: Select all
chargecount=0;


[PLAYER]
{KEYDOWN(Z)}
Code: Select all
chargecount+1;
(REPEAT)

[PLAYER]
{KEYUP(Z)}
Code: Select all
if (charge_count > 29);
{CreateActor("player_charge1", "machine_gun", "(none)", "(none)", 10, -4, false);};


WHAT AM I DOING WRONG? :?: :?
Upcoming projects: Twilight sKys 15% done, est. release Jan 1st
User avatar
toshiro
 
Posts: 22
Joined: Mon Nov 12, 2007 2:22 pm
Score: 0 Give a positive score

Re: CHARGE ATTACK

Postby Spidy » Sun Nov 25, 2007 2:42 pm

[PLAYER]
{KEYDOWN(Z)}
Code: Select all
chargecount+1;(REPEAT)


maybe this chargecount=+1;
Image
VOTE FOR MY SIGNATURE PLEASE.......THANK YOU
User avatar
Spidy
 
Posts: 935
Joined: Tue Aug 14, 2007 1:28 pm
Location: http://www.inatonibai.com
Score: 38 Give a positive score

Re: CHARGE ATTACK

Postby Rux » Sun Nov 25, 2007 9:59 pm

You put the set charge_count code on Draw actor instead of Create Actor.

You see, Draw actor does all the actions every frame until destroyed. Create Actor only does the action as soon as the actor is created. If your actor is created at the very beginning of the game with no Create Actor Action, it automatically creates itself.

So put the first code you mentioned on create actor instead of draw actor ok? :)
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score

Re: CHARGE ATTACK

Postby toshiro » Tue Nov 27, 2007 1:39 am

hey rux i tried what you said but the same thing is still happening... i dont kno maybe the way that i am going about it is wrong. How would you do it? :?: :?: :?: :idea:
Upcoming projects: Twilight sKys 15% done, est. release Jan 1st
User avatar
toshiro
 
Posts: 22
Joined: Mon Nov 12, 2007 2:22 pm
Score: 0 Give a positive score

Re: CHARGE ATTACK

Postby Rux » Tue Nov 27, 2007 1:59 am

Hmmmmmmmmmm, *Gasp*! I think you made a script error in the second script. Try
Code: Select all
chargecount = chargecount +1;


If that doesn't work I have something else in mind. Try it first.
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score

Re: CHARGE ATTACK

Postby toshiro » Wed Nov 28, 2007 1:41 am

OMG! why is it still not working? :? what else can i try?
Upcoming projects: Twilight sKys 15% done, est. release Jan 1st
User avatar
toshiro
 
Posts: 22
Joined: Mon Nov 12, 2007 2:22 pm
Score: 0 Give a positive score

Re: CHARGE ATTACK

Postby Spidy » Wed Nov 28, 2007 9:35 am

yep i said that two :x
Image
VOTE FOR MY SIGNATURE PLEASE.......THANK YOU
User avatar
Spidy
 
Posts: 935
Joined: Tue Aug 14, 2007 1:28 pm
Location: http://www.inatonibai.com
Score: 38 Give a positive score

Re: CHARGE ATTACK

Postby Kalladdolf » Wed Nov 28, 2007 10:29 am

Spidy wrote:
[PLAYER]
{KEYDOWN(Z)}
Code: Select all
chargecount+1;(REPEAT)


maybe this chargecount=+1;

chargecount +=1
!!!
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: CHARGE ATTACK

Postby Spidy » Wed Nov 28, 2007 10:57 am

yeah thats what i mean
Image
VOTE FOR MY SIGNATURE PLEASE.......THANK YOU
User avatar
Spidy
 
Posts: 935
Joined: Tue Aug 14, 2007 1:28 pm
Location: http://www.inatonibai.com
Score: 38 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest