Jump to content
  • Advertisement
Sign in to follow this  
martiniwanowski

How do I design my game engine?

This topic is 2544 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

Quick intro
I'm currently learning Python + Django, moving from previous experiences with PHP + Zend Framework and CodeIgniter. I have rather long experience with JavaScript and CSS, but
I am by no means a software engineer, rather a hobbyist with no professional education under my belt.

I'm working on a browser based game, a'la MOBA fashion. Utilizing a homemade - albeit simple - JavaScript+CSS "replay" game engine where I basically move images and display event text according to a complete text file. The text file is a "match protocol" which is in fully generated behind the scenes and then downloaded. There's no real-time streaming or such involved, and no networking. The events such as move, attack and so forth are based on time.

The problem
The behind-the-scene match generation is what I'm looking at now. Basically I want to simulate the battle rather than calculate a randomized-ish outcome. This way I can add (very) basic AI and treat the heroes as bots, in the future.

But how can I make my hero move from point A to B, and be sure I can start working on a new decision when it has arrived at a specific timestamp - when I know the main loop will take a different amount of time each loop. I can foresee this having major implications as the engine grows more complicated.

I was thinking I should divide each second into, ticks (I've read somewhere about this previously but I can be confusing this with some other technique), which I can then use to loop my game no matter how long each tick takes in time. Am I on the right track here or is there some other known technique I should be familiarized with?

I'm just having issues getting started. Once I have that I can start iterating my engine as need, but this is to me somewhat mind twisting and I can't make out how I'd go about designing this.

I appreciate any feedback regarding this issue. Resources, one-liner feedback and alike are all welcome. Thanks.

Sincerely,
miwnwski

Share this post


Link to post
Share on other sites
Advertisement
Hi, i'm not sure if this specifically relates to what you're doing, but i'm currently working on on a real time strategy game engine capable of multiplayer

the way my timestamp/tick system will work is, whenever the user makes some sort of input, selecting a unit, moving them etc, then that action is added to a buffer which is sent to the server at the next timestamp (or immediately, and it's determined by the server), when the server recieves it, it attaches it to the next avaliable timestamp and sends it back to all the clients
the idea of this system is to just send the inputs, and have it perfectly simulated on each client because of that
the way timestamps/ticks (will work on mine) work is, a timestamp is when the actions are updated, if no actions are made, it sends an empty message, when the client receives a timestamp, it adds it to a buffer for timestamps, which for example may occur every 2 seconds
between these timestamps are ticks, which arent actually sent to the server, the purpose of ticks, is to execute something a very specific amount of times between timestamps so it can be simulated on each client perfectly (without having to update things like, units position, health, etc, these are just perfectly simulated based on inputs)
let's say we have:
2 seconds between timestamps, and timestamps contain the users actions
30 ticks per timestamp, so that's 30 steps, or executions per second
timestamp 1: unit is told to move right 40 pixels at a speed of 1 pixel per tick
30 ticks pass, so it moves right 1 pixel per tick, totaling 30 pixels

if a new timestamp recieved is very far ahead of the current one the client is on, then they can just loop through the ticks and timestamps to catch up
for (int i =0; i<30; i++)
{
ents.tick();
}

i'm not familiar with javascript/css though, it sounds like it's a web based game (in which case, this post might not be too helpful to you)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!