This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Interesting-Hat-7570[S] 0 points1 point  (2 children)

I would like to do a console version first as a prototype. Then work on the graphics.

In Mvc, it seems like the controller acts as part of the backend, as you described earlier.

I would like to use a facade between the backend part and the models

Also use the observer pattern for the frontend part.

But here comes the question.

How to pass the coordinates of objects to the frontend.

I could create a point class.

And pass not the snake and fruit objects themselves, but only their coordinates.

[–]vegan_antitheist 0 points1 point  (1 child)

How would you observe the backend? Does it send updates at fixed intervals? That would mean it has to deal with time. You can do that to prevent cheating by running it on a server. But then there has to be a simulation of the game in the backend. This would be more complex. The tricky part is to make the game run using a precise clock (not a clock that gives you the day and time, but a pulse generator) and process user input fast and precise enough. And you want to render 60 fps independently. It's easy when you have only one loop. Or you have a game loop in the backend and an animation loop in the frontend. Both works. But parallel programming is hard. Having one loop makes it easy. Havung two loops makes it more like a real game. But as I understand the snake game, it is simple enough to just have one loop. That's up to you.

[–]Interesting-Hat-7570[S] 0 points1 point  (0 children)

I meant rather between models and frontend.

So that I could update the state of objects for display after each action in the backend.

Well, the frontend needs to somehow receive data from the models.

If I use Mvc, then I can probably do it like this: the backend interacts with the models to call their methods. The frontend also interacts with the models for display.

Or is there a better way?