How do I code correctly?

Get help using Construct 2

Post » Mon Sep 15, 2014 2:59 pm

Hi,

i am doing a spaceblaster game and dont know how to code correct interact different upgrades.

I have 2 Upgrades for the Laser. First upgrade changes the Lasersprite and some instancevariables like dmg and energyconsumption. The Second upgrade Changes the amount oh how many lasergungs ur ship has. picture for get better idea:

Image

Here is my code for finding which Lasertype to spawn

Image

I do this for 4 lasertypes by "Lasertype = 0" to "Lasertype = 3". Now i want to implement 8 upgrades for the number of laserguns (spawn more of the right Laser on different angle) and have to check a variable for the amount and one for the Type.

Question: Do i realy have to create 4 x 8 = 32 Events for that idea? i learned abeot arrays while searching for an idea, but dont get how i could use it for this situation.

Thanks for your time!

Her is my .capx
h*t*t*p*s://drive.google.com/file/d/0Bx3WDFOpgBMAT05QTnFzN1BmVW8/edit?usp=sharing
B
7
Posts: 16
Reputation: 315

Post » Mon Sep 15, 2014 6:41 pm

I add an instance variable to the player and then events to react. see attached sheet. if this does not help let me know and ill post a tutorial when i get home.
You do not have the required permissions to view the files attached to this post.
[b]Andrew Donelson[b]
Nlaak Studios, LLC
https://www.nlaak.com/
[email protected]
B
15
S
3
Posts: 66
Reputation: 1,136

Post » Mon Sep 15, 2014 6:45 pm

You'd be best to work with families, or use a single instance of "Laser" for all upgrades. I would also create a function to spawn lasers according to some parameters like position offsets, angle and power. With that, multiple spawns for different "Lasercount" values are easily created. I modified your capx to illustrate what I'm talking about. (I removed the backgrounds to reduce the filesize)
You do not have the required permissions to view the files attached to this post.
B
74
S
31
G
26
Posts: 994
Reputation: 20,198

Post » Mon Sep 15, 2014 8:20 pm

Thank u both!

@Magistross: You helped me much! Its pretty hard to search something u dont know its there, or even have a name (like function) to google. thank u for explaining and even changed my capx!

@nlaakald: Didnt get ur idea. Sure its me noobing around :) If it is not to much timeconsuming, i would like to understand what u told me.

Thanks!
B
7
Posts: 16
Reputation: 315

Post » Mon Sep 15, 2014 9:28 pm

Ok i am home let me pull my event sheet into an example and ill post it
[b]Andrew Donelson[b]
Nlaak Studios, LLC
https://www.nlaak.com/
[email protected]
B
15
S
3
Posts: 66
Reputation: 1,136

Post » Mon Sep 15, 2014 10:10 pm

Ok attached is a quick example of doing it. On yours, you are using different objects for each. Make your life easier, make a single Sprite for your Power Up or even power down. Lets say you have 10 different power ups and 5 downgrades. Put all 15 into a sprite as animation frames. Add an instance variable for the power up id or name. I use the text, easier to remember. Then you can random generate and place the power up object dynamically and in the event sheet you check for a collision with THE power up object and if so....What TYPE is it and react accordingly. Hope this helped.

you can see it in use at c2 dot i2tmlabs dot com (the games name is Crossroads)
You do not have the required permissions to view the files attached to this post.
[b]Andrew Donelson[b]
Nlaak Studios, LLC
https://www.nlaak.com/
[email protected]
B
15
S
3
Posts: 66
Reputation: 1,136

Post » Tue Sep 23, 2014 10:51 am

Thanks!
B
7
Posts: 16
Reputation: 315


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests