How do I code correctly?

0 favourites
  • 7 posts
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • 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:

    Here is my code for finding which Lasertype to spawn

    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

  • 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'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)

  • 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!

    : 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok i am home let me pull my event sheet into an example and ill post it

  • 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)

  • Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)