Mercurial > hg > pub > prymula > com
comparison lamertetris/sources/game.h @ 0:2787f5e749ae
INIT
author | prymula <prymula76@outlook.com> |
---|---|
date | Thu, 21 Sep 2023 22:33:57 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2787f5e749ae |
---|---|
1 /* | |
2 * LamerTetris 2 | |
3 * author: prymula | |
4 * date: 10-VI-2023 | |
5 * licence: Public Domain | |
6 * tool: Geany | |
7 * Program based on: | |
8 * -This source code copyrighted by Lazy Foo' Productions (2004-2020) | |
9 * and may not be redistributed without written permission. | |
10 * -Andrew Lim Chong Liang https://github.com/andrew-lim/sdl2-boilerplate | |
11 */ | |
12 | |
13 #ifndef GAME_H | |
14 #define GAME_H | |
15 | |
16 #include <SDL2/SDL.h> | |
17 #include <SDL_ttf.h> | |
18 #include <cstdio> | |
19 #include <iostream> | |
20 #include <unistd.h> // sleep access | |
21 #include <time.h> | |
22 #include <map> | |
23 | |
24 #if WINDOWS | |
25 #include <windows.h> | |
26 #include "hiscore_win.h" | |
27 #elif LINUX | |
28 #include "hiscore_linux.h" | |
29 #endif | |
30 | |
31 #include "field.h" | |
32 #include "szlam.h" | |
33 #include "text.h" | |
34 | |
35 | |
36 #define SIZEFONT 35 | |
37 #define SCOREFONT 20 | |
38 | |
39 enum { | |
40 DISPLAY_WIDTH = 400 | |
41 , DISPLAY_HEIGHT = 600 | |
42 , UPDATE_INTERVAL = 1000/60 | |
43 , HERO_SPEED = 2 | |
44 , SHAPE_SIZE = 200 | |
45 , BALL_SIZE = 75 | |
46 , RED_BALL = 0 | |
47 , YELLOW_BALL = 75 | |
48 , GREEN_BALL = 150 | |
49 , BLUE_BALL = 225 | |
50 | |
51 }; | |
52 | |
53 class Game { | |
54 public: | |
55 Game(); | |
56 ~Game(); | |
57 void start(); | |
58 void stop() ; | |
59 void draw(SDL_Rect *srcField, SDL_Rect *positionField, bool end); | |
60 | |
61 | |
62 void fillRect(SDL_Rect* rc, int r, int g, int b ); | |
63 void fpsChanged( int fps ); | |
64 void run(); | |
65 | |
66 private: | |
67 void up_direction(); | |
68 void left_direction(); | |
69 void right_direction(); | |
70 | |
71 std::map<int,int> keys; // No SDLK_LAST. SDL2 migration guide suggests std::map | |
72 int frameSkip ; | |
73 int running ; | |
74 SDL_Window* window; | |
75 SDL_Rect dst; | |
76 TTF_Font* gFont = NULL; | |
77 TTF_Font* fontScore = NULL; | |
78 SDL_Surface *background = NULL; | |
79 SDL_Surface *screenSurface; | |
80 SDL_Texture *texture; | |
81 HiScore hiscore; | |
82 int score, hi_score; | |
83 Text scoreTxt; | |
84 Field field; | |
85 Szlam szlam; | |
86 int color,n_element=0, figure=1, rate=1, tmp_element=0; | |
87 SDL_Rect positionField, srcField; | |
88 int left=0; | |
89 SDL_Renderer* renderer; | |
90 bool loadWallpaper(); | |
91 bool loadFromFile( std::string path, SDL_Renderer * renderer); | |
92 | |
93 }; | |
94 #endif //GAME_H |