Towers vs Zombies source code

I wrote the base of the game in about an hour but the complex part take me more than i would like so I am posting the code and set the state of the development to pause.
You can play with it, change the zombies with the zombies from Zombie example and examine the Towers to add one of your own design, see the video in Youtube:
http://www.youtube.com/watch?v=PjUYnDXfPA4

And here you are the source , my new baby xD
https://gist.github.com/1362916

I would like to know a better way of using math.random() before create a genetic algorithm for the se games… :slight_smile:

A genetic algorithm can be used for several distant topics as find a fitness value for a Mario Bross level jumping like this:
http://www.youtube.com/watch?v=j3__MP1IOfA
Lol
Another thing i wanted to do is draw the health bars with the actual size related to the current zombie or tower.

Why am i getting the same random values? Do I need to set a randomseed?

This is just amazing! Really awesome looking project, juaxix. Have you thought about making it run a bit faster? It moves at quite a slow pace in your video.

I think sound() can cause an issue with random(), does it happen after you use sound()? We’ll improve the random() library to use an isolated generator in the update after 1.1.2.

I saw the same issue with my particle stuff - try not setting the randomseed. It’s bugged in some way that I haven’t been able to figure out yet - it’s AS IF it’s getting called in the draw() loop, but it’s not.

FWIW Simeon - I’ve seen the same behavior without using sound(). I’ll see if I can isolate it.

randomseed takes an integer if that helps. It slipped me up once. random gives you a number between 0 and 1 by default so saying randomseed(random()) isn’t good.

randomseed(random(100000))

or something seems to work ok.

randomseed(random(Number)) dont seems to work along with this code, but nosound does…
I have accelerated the game ,fix minor bugs and now it works like a charm, oh i added a scene inspired by @voiceofreason xD
Now it has levels and different zombies hahá
Btw, the development state is still in pause mode until sound-random Bug fix appears ,maybe Simeon or another could make and share a new video with the game :slight_smile:

Runs nice :slight_smile: . I also tried it on my windows pc using lovecodify. Works too, but a bit too fast.

@juaxix: Have you thought about normalising your speed by using DeltaTime? For example, I notice lines like this in your source code:

self.position = self.position + self.velocity

Which is a pretty standard way to move things. However that will cause your position to change based on the speed of the device. If you do the following, however:

self.position = self.position + self.velocity * DeltaTime

Your position will update at a constant speed regardless of device speed. This should also improve compatibility with LoveCodify, as @SiENcE mentions.

(Note, self.velocity will need to be in different units - probably multiplied by ~60 or so to get it into pixels-per-second rather than pixels-per-frame.)

Edit: I realise the example code does not follow this practice. There’s no real excuse for that, the example code should do this too.

About the sound random bug.
You can fix this by doing (pseudocode):

r = random(100000)
sound(foo)
randomseed(r)

@Simeon do not push yourself so much, the examples are very good.
I will try Deltatime and random issues soon :slight_smile:
I working in a new prototype as well and i will use this, thanks

added to wiki https://bitbucket.org/TwoLivesLeft/codea/wiki/UserContrib

cool :slight_smile:

Siiiickkk

For some reason im just ending with a black screen, i have it all set up perfectly and i didnt forget anything, wierd

Try to set up the order of the files to be run in the same order in which appears in the gist…

Has anyone every made a game like super Mario or another arcade game on codea that was famous from 2000-2008

Have you seen @ruilov’s Pacman?

Pacman is in CC for anyone :slight_smile:

@juaxix, Why dont you upload the code to Codea Community? It will save a lot of time for the users instead of individually copying and pasting from gisthub