Page 1 of 1

levels and actors

PostPosted: Wed Oct 19, 2016 1:28 am
by ckn087
What is the best way to make actors? I'm wanting to add a new enemy character each level. Like level 1 has 1 enemy, level 2 has 2 enemy characters and so forth. Everytime I kill one of the 2 on level 2, it destroys both of them? I don't understand what i'm doing wrong. I have a variable that is global integer so that they have to be shot 3 times before they get destroyed. Also what is the best way to create levels? I have them in separate ged files but i heard that wasn't the best idea in case i want to change a character like (player) because i would have to change it in every ged file.

Re: levels and actors

PostPosted: Wed Oct 19, 2016 4:27 pm
by Hares
You are using a global variable for the damage, but in this case you want to use a actor variable.

If you use a global variable, that means there is 1 variable in the whole game.
So any time you register damage, it will register to this 1 variable.

If you make an actor variable, then each actor will have his own instance of that variable.
Now when you take damage, you only affect the variable for that 1 actor.

Re: levels and actors

PostPosted: Wed Oct 19, 2016 11:49 pm
by ckn087
Ok here is what I have done. I have made an enemy actor (enemy1) I made an array of about 5 of them by clicking clone. I made a variable called enemy_hits. I have it set in script editor to where when player bullet collides with enemy 1 (enemy_hits --; and it is set to actor variable now and they still all die at once. Idk what I done wrong lol thanks for any help I can get!

Re: levels and actors

PostPosted: Fri Oct 21, 2016 11:04 am
by schnellboot
As Hares already said, it is important to declare the variable as "Actor Variable" and not "Global".

Re: levels and actors

PostPosted: Sat Oct 22, 2016 6:52 pm
by ckn087
It was already set as actor variable. I found my problem. I had an event set to draw actor/script editor: if enemy_hits ==0 destroy enemy instead of destroy event actor. Lol thanks for the help guys

Re: levels and actors

PostPosted: Wed Oct 26, 2016 8:32 pm
by Hares
ckn087 wrote:Also what is the best way to create levels? I have them in separate ged files but i heard that wasn't the best idea in case i want to change a character like (player) because i would have to change it in every ged file.

I would make multiple .ged files:
- One for the intro and/or menu
- One for each level

When you export the intro (file -> export), you choose an executable file format. This will generate an .exe file
When you export the levels, you choose "game data only". This wil generate a .dat file, which is the same as the exe but without the game engine included.

In your game you just load the .dat file with the load game function(LoadGame("Level1.dat")

The tricky thing is that if you have variable that should keep it's value (score, lifes, upgrades, ...) you should export the variables to a text file before you load a new level, and read the text file after loading the level.

Hope this helps