Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Towers vs Zombies source code

edited November 2011 in Code Sharing Posts: 437

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:

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... :-)

A genetic algorithm can be used for several distant topics as find a fitness value for a Mario Bross level jumping like this:

Lol
Another thing i wanted to do is draw the health bars with the actual size related to the current zombie or tower.

Comments

  • Posts: 437

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

  • SimeonSimeon Admin Mod
    Posts: 4,759

    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.

  • BortelsBortels Mod
    Posts: 1,557

    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.

  • BortelsBortels Mod
    Posts: 1,557

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

  • DylanDylan Admin Mod
    edited November 2011 Posts: 121

    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.

  • edited November 2011 Posts: 437

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

  • Posts: 24

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

  • SimeonSimeon Admin Mod
    edited November 2011 Posts: 4,759

    @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.

  • DylanDylan Admin Mod
    edited November 2011 Posts: 121

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

    r = random(100000)
    sound(foo)
    randomseed(r)
    
  • Posts: 437

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

  • Posts: 437

    cool :)

  • Siiiickkk

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

  • Posts: 437

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

  • Where's the code?

  • Posts: 60

    @lruizlopez137 First post for the WIN.

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

  • edited October 2013 Posts: 355

    @juaxix this is perfect , I love the sense of play.
    how long did it take to do?

  • Where is the code

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

  • Posts: 2,042

    Have you seen @ruilov's Pacman?

  • Posts: 355

    Pacman is in CC for anyone :)

  • Posts: 835

    @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

  • Can someone please tell me what codea community is?

Sign In or Register to comment.