space Game

Non-platform specific questions.

space Game

Postby praaab » Sun Feb 19, 2012 5:35 pm

well ive been trying to get my spaceship to destroy wen it hits the asteroids, my cod is this
hp=2;
if(hp = 0)
{
destroyactor
}
but y wont it work??
praaab
 
Posts: 82
Joined: Sat Jun 18, 2011 2:14 pm
Score: 1 Give a positive score

Re: space Game

Postby SuperSonic » Sun Feb 19, 2012 5:39 pm

it should be: hp-=2; :wink:
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: space Game

Postby praaab » Sun Feb 19, 2012 5:58 pm

i know in my collision with asteroid its hp-=1;
and i set the hp to 2 in my create actor, in the collision also its the if(hp=0) then destroy actor
but it still wont work
praaab
 
Posts: 82
Joined: Sat Jun 18, 2011 2:14 pm
Score: 1 Give a positive score

Re: space Game

Postby SuperSonic » Sun Feb 19, 2012 8:09 pm

Oh I'm sorry. I was wrong :P

The correct code should be:if(hp == 0)

Notice the double equal marks. This is used to check if something is equal. Just a single mark will change something. For example:
Code: Select all
int i;
i = 5;//This will make i equal five
i == 5;//This checks to see if i is equal to five

I hope that made sense^^
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: space Game

Postby praaab » Mon Feb 20, 2012 11:30 pm

nw see im proposing my lives system, how should i make so that if lives-- then destroy actor cause in my collision with asteroid it has lives--; and then it says if(lives--) then destroy actor, but all it does is take away 2 lifes and destroys the actor. (i set the lives to 3)
praaab
 
Posts: 82
Joined: Sat Jun 18, 2011 2:14 pm
Score: 1 Give a positive score

Re: space Game

Postby skydereign » Tue Feb 21, 2012 12:01 am

You need to be able to distinguish between setting and comparing variables.
Code: Select all
x++; // increases x by 1
x+=1; // increases x by 1
x=1; // sets x equal to 1
x==1; // checks if x is equal to 1

Notice the only comparison is when you use two equal signs. So putting lives-- into an if statement won't check if lives is a certain value, all it will do is reduce lives by 1. You can also use !=, >=, >=, >, and < to compare numbers. These do not change the value of the variable, instead they return a 1 or a 0 (1 meaning true and 0 meaning false). As SuperSonic mentions you need something that decreases your variable, and then checks if it is equal to 0.
Code: Select all
hp--;
if(hp<=0)
{
    DestroyActor("Event Actor");
}

If you don't use the format of reducing the variable and comparing, you'll come across the problems you have been facing.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: space Game

Postby praaab » Tue Feb 21, 2012 1:15 am

but how do i make it so that IF he loses a life then destroy actor but comes back after 1 second?
praaab
 
Posts: 82
Joined: Sat Jun 18, 2011 2:14 pm
Score: 1 Give a positive score

Re: space Game

Postby skydereign » Tue Feb 21, 2012 2:22 am

That's simple, put that code where he loses a life... right? To actually make the actor actually be destroyed you can either destroy it temporarily and recreate it after a second (using a timer) or you can change its visibility state and reset it after a timer event.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: space Game

Postby praaab » Tue Feb 21, 2012 2:23 am

heres the link to download my game http://www.filedropper.com/raadproductions
praaab
 
Posts: 82
Joined: Sat Jun 18, 2011 2:14 pm
Score: 1 Give a positive score

Re: space Game

Postby skydereign » Tue Feb 21, 2012 2:46 am

Now am I to assume that means you want me to fix the problem? Two things to note, one is that you have two collision events with the same actor (colliding with the asteroid). You should really combine these two, and in the second one you have an if statement followed by a semicolon. That semicolon makes the if act as if it were always true, which is why the particle effect happens when lives are still greater than zero. Now the second thing is you never recreate the player actor. I would recommend creating a timer for the view that lasts a second. In this timer event the view should recreate the player in the center of the screen.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: space Game

Postby praaab » Tue Feb 21, 2012 3:32 am

this is all very confusing to me is there any way that u could fix these problems with the view and respawning?
praaab
 
Posts: 82
Joined: Sat Jun 18, 2011 2:14 pm
Score: 1 Give a positive score

Re: space Game

Postby skydereign » Tue Feb 21, 2012 11:06 pm

You mean like this? I changed a few other things and I'm not sure what you meant by the problem with the view.
Attachments
raad production.ged
(8.57 KiB) Downloaded 122 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: space Game

Postby praaab » Wed Feb 22, 2012 8:30 pm

i have that done already i found out how to do it but thanks a lot for the effort heres +1, and i have a question i want my space ship to become faster wen he collides into an speedupgrade.
praaab
 
Posts: 82
Joined: Sat Jun 18, 2011 2:14 pm
Score: 1 Give a positive score

Re: space Game

Postby skydereign » Thu Feb 23, 2012 12:28 am

You'll notice in my edit I removed the draw actor events that only moved the actor (x+=1). So now it uses xvelocity which is set to 1 during the actor's create. So if you want to increase the speed just increase xvelocity when you collide with a speedup actor (you should probably also increase the view's xvelocity).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest