dynatown 2

Posted by dswscorpion on Jan. 19, 2012, 7:13 p.m.

Hey all, i have been working on the dynatown 2 game, and i really wasn't gonna do it.But i took the game to my moms house and she loves it.So i thought i would do my idea of the part 2 ,this time i was gonna add some variables like global.electricity and if enough electricity was there then operate the houses and buildings, also i want to create the roaches that are in the story of part one, to actually see them on this one, and when the house or building gets to many roaches on them disable them, i have got the graphics already for the houses that are in part one ,to show disable and repair and such over them.but last night when i got the 18 house objects and the wood buildings done, i was attempting to create the bugs with a timer, and the timer works, it just produces the roach every so often like 1 every second.i can do that part of it, it's just that i have never worked with to many a.i. of the enemy's except for space games, and they generally go straight or i a simple path,this one is a little different they have to be able to go for a house or an object, and add up on the houses i have no idea how

Comments

panzercretin 12 years, 10 months ago

Protip: Every game developer's mum loves their games, even if they have no clue what they are looking at.

As for making them go to different houses… well, do you do coding or DragnDrop?

dswscorpion 12 years, 10 months ago

@panzer i can do both ,the only way i know would be to set a lot of paths up and just with a chance pick one but that would look not like the thing i want to do

panzercretin 12 years, 10 months ago

Well, first off, we'd need to pick which house they would go for. I'll assume for now that each roach goes for a completely different house. The code in the creation event for a roach would have something like this in it:

var tx,ty;
tx=random(room_width)
ty=random(room_height)
target=instance_nearest(tx,ty,house)
destx=target.x
desty=target.y

Pretty much what I'm doing there is making it choose a random point, then choose the closest house to that point. Then you figure out the x and y coordinates of said house (I'm assuming houses don't move around much so the position doesn't need to be updated).

Now that we know where to go, it's just a matter of getting there. Idunno how big or how fast you want the roaches to be, but it could look similar to this:

speed=min(10,max(0,distance_to_point(destx,desty))
direction=point_direction(x,y,destx,desty)
image_angle=direction

Replace 10 with whatever speed works best aesthetically.

Rob 12 years, 10 months ago

Quote:
18 house objects

OOP. You are doing it wrong.

panzercretin 12 years, 10 months ago

Maybe you mean 18 instances of the house object itself?

Rob 12 years, 10 months ago

I sure hope he does.

colseed 12 years, 10 months ago

^

if not, make it so

copying/modifying code to fit 18 different objects is far too much work

panzercretin 12 years, 10 months ago

I remember before I knew about image_angle and I made all the sprites that I wanted to rotate have 360 subimages, one for each degree.

Castypher 12 years, 10 months ago

Before image_alpha was screen-door transparency. YEAH.

Rob 12 years, 10 months ago

Quote:
I remember before I knew about image_angle and I made all the sprites that I wanted to rotate have 360 subimages, one for each degree.

Christ. I used to do that before I had registered, but I would only do 18 or 36 ones. Didn't that take forever to load?