Enemy random start

Game Editor comments and discussion.

Enemy random start

Postby sniperpike » Wed Aug 22, 2007 9:49 am

I need enemies to be deployed within a specific range of time. (Random time within fx 1 minute, so not all of the enemies start their movement towards the player at the same time)

Can anyone help me ?
If, please be VERY specific, im into graphics, not programming.
sniperpike
 
Posts: 18
Joined: Thu Aug 09, 2007 11:57 am
Score: 1 Give a positive score

Postby pixelpoop » Wed Aug 22, 2007 8:19 pm

random creation would be a little harder so how about creating them one after the other?

create a variable integer i

i++;
if (i==3){CreateActor(); i=0;}
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby motorollin » Thu Aug 23, 2007 8:48 am

Random creation wouldn't be that hard. Just create a timer with a time of, say, 10 seconds. Create an on timer event which triggers a script. In that script generate a random number between 1 and 10. Then check if the random number is, say, less than 4, for a 3 in 10 chance that an enemy will be created. If the random number is less than 4, then create an enemy and increment a variable, say, "numenemies". When numenemies reaches the maximum number of enemies you want on the screen, destroy the timer.

EDIT -
This has the added advantage the any time you want to "top up" the number of enemies on the screen you just re-create the enemy creation timer. You could also create a variable "maxenemies" to check whether your maximum enemies on screen has been reached, and in later levels you could increase maxenemies before creating the enemy creation timer in order to cause more enemies to be created.
motorollin
 
Posts: 54
Joined: Sun Aug 12, 2007 8:05 am
Score: 1 Give a positive score

Postby Freddy » Thu Aug 23, 2007 9:36 pm

An very simple way to do it would be to make the actor that creates the enemies go on a path, so that their positions would be random. And if you want the bad guys to be created only when there is less than five of them, you would need to do this.
On the create actor event of the actor that creates the enemy, go to script editor and write:

numenemies = 0;

Then in the timer event of youre same actor, go to script editor and write:

if(numenemies<5)
{
CreateActor("your enemy", "icon", "(none)", "(none)", 0, 0, false);
}

Then, go to the create actor event of your enemy, and go to script editor and write:

numenemies = numenemies + 1;

Then go to the destroy actor event of the enemy, script editor, and write:

numenemies = numenemies - 1;

Hope this helps 8)
Im going to be posting my mini-game "X-Terminator" (pun intended) which has just about everything what I think you want to know about :D
User avatar
Freddy
 
Posts: 548
Joined: Sat Jun 02, 2007 3:42 pm
Location: Why do you want to know?
Score: 14 Give a positive score

Postby sniperpike » Fri Aug 24, 2007 6:21 pm

This even I can understand how to do.......
very specific..thanks a lot, im going to try that.....
sniperpike
 
Posts: 18
Joined: Thu Aug 09, 2007 11:57 am
Score: 1 Give a positive score

Postby sniperpike » Fri Aug 24, 2007 7:00 pm

I've got this error, when typing "numenemies = 0;" :

Error line 1: Incompatible types: cannot convert from ´cont int´ to 'Identifier'


As I said......im not into coding....just a beginner who would like to learn :)


and this, I dont no how to do....... dont know how/where to find "timer event of your actor".
Then in the timer event of youre same actor, go to script editor and write:

if(numenemies<5)
{
CreateActor("your enemy", "icon", "(none)", "(none)", 0, 0, false);
}


Thx for the trouble....
sniperpike
 
Posts: 18
Joined: Thu Aug 09, 2007 11:57 am
Score: 1 Give a positive score

Postby Freddy » Fri Aug 24, 2007 7:57 pm

OK, this seems like alot of stuff, but its just because its laid out step by step, I think you should be able to get through it all. :wink:
Sorry about the timer thing, I assumed that you already had the timer made, I dont know why... Anyway, I used to get frustrated with your problem with the numenemies. To the computer, its a bunch of nonsense, that is until you make it a variable. I also assumed you knew how to do this, sorry. What you need to do is, on the tool bar, you will find a button called "script'. Press it, and youll find a script editor screen. You need to find the button that says "variable" (note: not variables/functions). Click on it. A menu will pop up. Click add and you will find a new menu, dont worry about anything except the name at the top. Type in numenemies, and click add. Then you can close out and everything should be fine :D . About the timer, if you hav'nt made a timer for the actor that creates the enemies, you need to do so. This is how to do it, if you have already made the timer, you dont need to read anything under the 1.

1. To make a timer, go to the actor control of the actor that makes the enemies. Then, in the events, select the "draw actor" event. Then select the "create timer" action. Press the "timer" button in the new menu, and select "new timer". You can name it whatever you want, in the next box, type in 5000 to make the timer go off after 5 seconds (you can choose how long you want it to be if you dont like 5 seconds). Then click ok, and you made a timer! :D

2. The "timer" event is in the events button on the actor control of the actor that creates the enemies. Select "timer" and a timer menu should show up. Press the timer button and select the timer you made. Then press add action, and press "script editor". In the script editor, write:

if(numenemies<5)
{
CreateActor("your enemy's name", "icon", "(none)", "(none)", 0, 0, false);

Press add, and youre done!!!!! :D If you have any problems just tell me. :D
Hola
User avatar
Freddy
 
Posts: 548
Joined: Sat Jun 02, 2007 3:42 pm
Location: Why do you want to know?
Score: 14 Give a positive score

Postby sniperpike » Fri Aug 24, 2007 10:16 pm

Thanks a lot for the effort in that explanation. learned something new :)
It kinda solved my problem, but created others :

The actor (enemy) created are the PACMAN sprite (and not my animation), until I hit it (then it plays the right anim), cant figure out why?

When I shoot and hit one enemy, the other enemies just created, disapear ???
:roll:
sniperpike
 
Posts: 18
Joined: Thu Aug 09, 2007 11:57 am
Score: 1 Give a positive score

Re: Enemy random start

Postby sniperpike » Sun Aug 26, 2007 3:43 pm

I found out about the pacman thing... :), I had yo change "ICON" to my animation-name :)

But it gave me a new problem, the animation are facing the same direction, nomatter from where it is created.
Is there some way I can make it face the center of the screen (0,0) ?? (Its moving towards the center of the screen)
sniperpike
 
Posts: 18
Joined: Thu Aug 09, 2007 11:57 am
Score: 1 Give a positive score

Re: Enemy random start

Postby sniperpike » Mon Aug 27, 2007 4:25 pm

Come on...?? ..... no one???

Or isnt it possible?¨
sniperpike
 
Posts: 18
Joined: Thu Aug 09, 2007 11:57 am
Score: 1 Give a positive score

Re: Enemy random start

Postby pixelpoop » Mon Aug 27, 2007 4:41 pm

how about something like this on the create actor event:

if (x<150)change animation code to face right
if (x>150)change animation code to face left
//change 150 to whatever the center x coordinate is for the center of the screen
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Re: Enemy random start

Postby sniperpike » Wed Aug 29, 2007 1:26 pm

The problem is, I can't code this. Maybe it is possible, but I just cant. I searched the forum, and it seems that no-one else could fix this problem.
So instead of having my enemy-actor (a human soldier) walking towards my player-actor (And turning the sprite-animation accoordingly), I now have to make new enemies (Not humans but flying saucers or alike, where it doesnt matter wich way they turn)

But thanks for your help, I know you all do your best. And I learned something new :)
sniperpike
 
Posts: 18
Joined: Thu Aug 09, 2007 11:57 am
Score: 1 Give a positive score

Re: Enemy random start

Postby pixelpoop » Wed Aug 29, 2007 8:00 pm

oh, you are talking about having GE rotate the sprite for you. No, GE doesn't rotate sprites. You could use a graphics program and rotate your actor a bunch of times so you have a bunch of files with your actor turning and then have GE go to the correct animation so it is facing the center.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Re: Enemy random start

Postby sniperpike » Sat Sep 01, 2007 10:01 pm

That would, in this case, require a lot of frames :

A human walking seen from top (30 frames), in at least 32 direction (To make it smooth) = 960 frames, for a character to walk.... and I need several differnt characters..... ohhh...........

I have seen some discussion on the forum, about wether the coming version of GE should have a ROTATE SPRITE function or not.

Some says it would require to much processor-power to be running smoothly.

What if GE precalculated the sprites that should rotate, before game starts (Shouldnt take more than a couple of seconds even with many sprites), stored the pictures/frames in memory, and played them in a sequence in the game. ???
sniperpike
 
Posts: 18
Joined: Thu Aug 09, 2007 11:57 am
Score: 1 Give a positive score

Re: Enemy random start

Postby pixelpoop » Sun Sep 02, 2007 2:39 am

Having a rotate sprite function would run slow on some handheld devices, but that also depends on how much else the cpu is processing. For a simple game it would probably run fine. Plus a lot of people here program for a desktop and you probably wouldn't notice any hit in performance on one.
Your idea for GE to export the rotated sprites into files on its own is good. I would imagine that would take a lot of programming on Makslane's part, maybe too much.
and if you haven't gone to the feature request post that I put up and voted for a rotate sprite function, please please do so! and maybe add your idea to that thread as well.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron