- This game is to be run on a device with minimum resolution of 1280x720
- The terminal that this game is run in is to be fullscreen.
- This is a very minimal game and should not require much graphical processing power
http://gameprogrammingpatterns.com/game-loop.htmlgame-loop-simple.png
A Game loop has ->
- An Input Processing Phase
- A Game Update Phase
- A Render Phase
While rendering a 2D game -> We use a Coordinate Plane. The 2D Coordinate System used is initialized as follows :
The standards implementing terminal colours began with limited (4-bit) options. The table below lists the RGB values of the background and foreground colours used for these by a variety of terminal emulators:
https://i.stack.imgur.com/9UVnC.png
The ANSI escape sequences we're looking for are the Select Graphic Rendition subset. All of these have the form
\033[XXXm
Where XXX
is a series of semicolon-seperated parameters
To say, make text red, bold, and underlined (we'll discuss many other options below) in Python3 you might write:
print("\033[31;1;4mHello\033[0m")
and in Bash you'd use
echo -e "\033[31;1;4mHello\033[0m"
where the first part makes the text red (31
), bold (1
), underlined (4
) and the last part clears all this (0
).
(Refer to the table in the linked article for all the Properties that can be set.)
It is Simpler for everyone to just use RGB and hence we will use :
\033[38;2;<r>;<g>;<b>m #Select RGB foreground color
\033[48;2;<r>;<g>;<b>m #Select RGB background color
We need a way to take input in the game without blocking the runtime at the input space.
The game will keep running in the blackground.
If I visualise the Game as a State Stack - The inputStream is seperated logically from the states, and acts as a general control for the states.