-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (67 loc) · 2.93 KB
/
main.cpp
File metadata and controls
74 lines (67 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <SDL.h>
#include<SDL_image.h>
#include <iostream>
#include"RenderWindow.hpp"
#include"Entity.h"
#include<SDL_mixer.h>
using namespace std;
int main(int argc, char* argv[])
{
int state = 1;
if (SDL_Init(SDL_INIT_VIDEO) > 0) {
cout << "SDL_Init failure ." << SDL_GetError() << endl;
}
if (!IMG_Init(IMG_INIT_PNG)) {
cout << "IMG_Init failure." << SDL_GetError() << endl;
}
RenderWindow window("GAME v1.0", 1280, 720);
SDL_Texture* ballTexture = window.loadTexture("images/ball.png");
SDL_Texture* holeTexture = window.loadTexture("images/hole.png");
SDL_Texture* pointTexture = window.loadTexture("images/point.png");
SDL_Texture* tileDarkTexture32 = window.loadTexture("images/tile32_dark.png");
SDL_Texture* tileDarkTexture64 = window.loadTexture("images/tile64_dark.png");
SDL_Texture* tileLightTexture32 = window.loadTexture("images/tile32_light.png");
SDL_Texture* tileLightTexture64 = window.loadTexture("images/tile64_light.png");
SDL_Texture* ballShadowTexture = window.loadTexture("images/ball_shadow.png");
SDL_Texture* bgTexture = window.loadTexture("images/bg.png");
SDL_Texture* uiBgTexture = window.loadTexture("images/UI_bg.png");
SDL_Texture* levelTextBgTexture = window.loadTexture("images/levelText_bg.png");
SDL_Texture* powerMeterTexture_FG = window.loadTexture("images/powermeter_fg.png");
SDL_Texture* powerMeterTexture_BG = window.loadTexture("images/powermeter_bg.png");
SDL_Texture* powerMeterTexture_overlay = window.loadTexture("images/powermeter_overlay.png");
SDL_Texture* logoTexture = window.loadTexture("images/logo.png");
SDL_Texture* click2start = window.loadTexture("images/click2start.png");
SDL_Texture* endscreenOverlayTexture = window.loadTexture("images/end.png");
SDL_Texture* splashBgTexture = window.loadTexture("images/splashbg.png");
SDL_Texture* menuTexture = window.loadTexture("images/menu.png");
Entity e(coordinates(100, 400), ballTexture);
Entity f(coordinates(308, 106), holeTexture);
Entity intro(coordinates(50, 70), logoTexture);
bool game = true;
SDL_Event event;
Mix_Chunk* Sound_charge = Mix_LoadWAV("sfx/charge.mp3");
Mix_Chunk* Sound_swing = Mix_LoadWAV("sfx/swing.mp3");
Mix_Chunk* Sound_hole = Mix_LoadWAV("sfx/hole.mp3");
SDL_Color White = { 255, 255 ,255 };
SDL_Color Black = { 0,0,0 };
while (game) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT)
game = false;
if (state == 0) {
window.clear();
window.Background(menuTexture);
//window.render(intro);
}
else {
window.Background(bgTexture);
window.render(e);
window.render(f);
}
window.display();
}
}
window.cleanUp();
//SDL_Quit();
return 0;
}