Space Invader trouble

Get help using Construct 2

Post » Tue Feb 21, 2012 3:40 pm

in your game, as I remember, you had something like "every 3 seconds, pick random enemy and shot"
But this value "3 seconds" cannot be changed as it is. You cannot transform an every 3 seconds into an every 2 seconds. 'Cause the value is kinda hard coded.

However, if you use something that represent a number instead of a real number, you just have to change this representation.
It's basically what's great about variable.

Let say I create a variable that represent the fire rate
let's call it fireRate. And let say it's a global variable 'cause it conserns many objects.

Ok so we have this variable. Now instead of "every 3 seconds" we write "every fireRate second"

Now you can modify however you want this representation. If you set fireRate to 2 it will be "every 2 seconds" if you set fireRate to 0.5 it will be "every half a second" etc.


The same idea goes with "in which level am I ?"
That's not the true question, the true question is "how many Level did I win?"
So you can have a variable named "level" to which you add 1 each time you win a level. But as a matter of fact, this value will also represent the level you're in, 'cause each time ou win, your level should increase.

And then you just have to put in a text box
set text to "Level "&level

In short variable are used to control what can vary in a program.
That's allYann2012-02-21 15:41:47
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Feb 21, 2012 3:51 pm

I think I actually understood that. O.o

I have to go somewhere but when I get back I will try. Thank you Yann.

EDIT- (For anyone who has similar trouble) I have fixed my fire rate problem. Meaning I made it so my person fires less often so the player can not simply hold the button and send a crazy amount of bullets.

What I did was this.



Add an event.
System- "Every X Seconds" I set X to 0.3 (You may want slower or faster)
Add another condition- Select Keyboard and then "key is down".
(I picked the space bar as my key but you can choose whichever key.)

After this click "add action" next to the first event "System- "Every 0.3 Seconds"
Then select your player and click "spawn another object".
Choose your bullet as the object to spawn, and set it to spawn at Layer 1, image point 0.

(Unless you are doing space invaders ignore this step)
Add another action below this one, select your "bullet" icon and then select "set angle", set it to 270.

Then select "audio", followed by "play" and your sound file for when a bullet shoots.




After doing all this the player no longer fires as often.
I put this is all descriptive as I could for those who do not know what to do like I wish I had found.


EDIT- There seems to be a few bugs with doing this. If anyone can fix that it would be awesome.Sheep2012-02-22 21:01:16
B
8
S
4
G
3
Posts: 69
Reputation: 2,556

Post » Wed Feb 22, 2012 4:10 pm

TITLE SCREEN

I followed this tutorial http://www.scirra.com/tutorials/53/how-to-make-a-port-of-1945-using-construct/page-7 on making a title screen. For those of you who do not want to watch the video I will explain how to make one.



First off create a new layout, we will call it "Title Screen".
When it asks if you wish to create an event sheet along with it select "Add event sheet".

By this point in your game I will assume you have already learned about sprites and all of that jazz so we will not get too detailed on them.

First, add your sprite (If you created one) for the title of your game.
Center it as best as you can wherever you wish. (top, middle, bottom, side, wherever)

Next, double click outside of your game area (the white space around your game) and when the object tab opens, select "Text" under the "General" section.

Depending on what you wish your game to say make the text say something along the lines of "Play" or "Click here to play". Title this text object as "Play". (You can use whatever but the rest of this will make more sense if you use that)

Yet again center this where you want it.
Customize the color, font, size, etc. how you wish.

For now we are only worrying about the "Play" text so don't add any other texts just yet.

Go to your "Event Sheet" (be sure to remember which one applies to this layout) and click "Add event"

(We will assume you want to click with the mouse, if not do the same but with a keyboard function)
Select the "Mouse" icon, and then click "On object clicked".

Choose whether you want it to work on left or right click, and leave "Click type" on "Clicked".
Where it says "Object clicked" select the text icon that says "Play" we created earlier and hit "Ok".

Next to this event we just created for the mouse click "Add action".
Go to the "System" icon and find "Go to layout". Select "Go to layout" and then choose "Layout 1" or whatever your game layout is titled.


Run your layout and your title screen should be the first thing to show up. You should be able to click "Play" (or whatever you put) and it should take you to your game.

If for some reason it takes you to your game first, go back to Construct 2 and drag the tab that says "Title Screen" and put it on the right on the one that says "Layout 1" or whatever your game layout is titled.

If you did everything right you should now have a title screen that you can interact with. Just as you did with the "Play" button. You can add more sprites/text objects to interact with by doing the same thing but using their respective names.


FOR EXAMPLE- Let's say you want to add one of your characters to the title screen so people can click them and go to a page that has his/her/it's biography or something.
You would add the sprite, follow the same steps (creating a new layout, event sheet, and all) and create his biography page.

The sprite would have to be put into your "Title Screen" layout, but when you do the steps for clicking it with your mouse, you change the layout it goes to, to the layout you created his biography in.


If you have any questions on this feel free to comment here and I may (or may not depending on how far in the future you respond) help you.


B
8
S
4
G
3
Posts: 69
Reputation: 2,556

Previous

Return to How do I....?

Who is online

Users browsing this forum: flemmig, Kagubro, MisterAqua and 24 guests