How do I set up an environment for my bugs and keep motivation?

0 favourites
  • 4 posts
From the Asset Store
*********** Fidget popper tile sets **************
  • I'm trying to set up a game a bit like the old virtual villagers games for my nan before she passes as she always complains about how the new ones suck.

    Although this is my first day working on the game I already feel like I've reached a barrier in my messy code...

    I was wondering if someone would be able to help me fix it and tidy my code a bit. I basically want the bugs which will eventually become villagers go to the food source and water source when they are hungry or thirsty, however I don't want them to bounce between them. (They go to the water to get 5 water, then they go to the food to get 5 food then the water ect)

    Basically I want them to be able to survive efficiantly without just sitting on the water and food. Here is what I've got so far but it just isnt working.

    I was wondering if anyone could tidy the code up for me or maybe tell me how to fix the issue I'm having with the water and food.

    dropbox.com/s/unos84rdck9uv56/Movement.c3p

  • I took a look at your code and noticed you are using functions and for each statements. I couldn't help but think this could be easier with a state machine.

    For a state machine, you need to give your objects a state and update the state according to their needs. For example, a bug would start at an idle state. Then, when they need to eat, they enter a searching for food state. When they find food, they enter an eating state, etc...

    I threw together a quick example that shows the principle in action. Hopefully it gets you closer to completing your project.

    drive.google.com/file/d/1vObtjdJppTivblySf-rn0Vx4bUH2fYTn/view

  • I have a wondering, eating and drinking state no? Maybe I accidentally shared an older file.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I took a look at your code and noticed you are using functions and for each statements. I couldn't help but think this could be easier with a state machine.

    For a state machine, you need to give your objects a state and update the state according to their needs. For example, a bug would start at an idle state. Then, when they need to eat, they enter a searching for food state. When they find food, they enter an eating state, etc...

    I threw together a quick example that shows the principle in action. Hopefully it gets you closer to completing your project.

    https://drive.google.com/file/d/1vObtjdJppTivblySf-rn0Vx4bUH2fYTn/view?usp=sharing

    OMG Thank you that code is so useful!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)