-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
159 lines (133 loc) · 3.9 KB
/
main.cpp
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <SDL2/SDL.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>
//#include <utility> // for const_cast<int>()
#include "files/qBMP.cpp"
#include "files/character.cpp"
#include "files/SDLinterface.cpp"
const int sWIDTH = 640;
const int sHEIGHT = 480;
const int sByron = 123;
#define xyy_debug1 //SDL_GetMouseState( &mx, &my ); std::cout << "(" << mx << "," << my << ") ";
#define xyy_debug2 //std::cout << (short)(e.button.button) << "_d(" << mx << "," << my << ") \n";
#define xyy_debug3 //std::cout << (short)(e.button.button) << "_u(" << mx << "," << my << ") \n";
#define xyy_debug4 //std::cout << "key: " << e.key.keysym.sym << "\n";
#define xyy_debugX //some other debug code (currently commented out)
#define xyy_debugX //some other debug code (currently commented out)
#define xyy_debugX //some other debug code (currently commented out)
#define xyy_debugX //some other debug code (currently commented out)
/*
draw(SDL_BlitSurface h1, SDL_Rect rs, SDL_BlitSurface h2, const SDL_Rect rd)
{
//SDL_Rect r1 = {0,0,32,32};
//SDL_Rect r2 = {0,0,32,32};
//const SDL_Rect *rs = &r1;
//SDL_Rect *rd = &r2;
SDL_BlitSurface( h2, rs, h1, rd );
}
*/
// ========================================================================
// ========================= MAIN ===================================
int main( int argc, char* args[] )
{
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { return 0; }
int appFLAG=0;
SDL_interface wind;
qBMP xHi("images/hi.bmp");
qBMP xAloha("images/aloha.bmp");
qBMP xBlack("images/black.bmp");
clsMover man1;
man1.img = xHi.xSurface;
man1.imgbg = xBlack.xSurface;
man1.winSurface = wind.xSurface;
unsigned int i=0;
// ====================== EVENTS ====================
SDL_Event e;
while(appFLAG==0)
{
int mx; int my;
while( SDL_PollEvent( &e ) != 0 )
{
//printf("= %i\n", e.type);
if( e.type == SDL_QUIT )
{
appFLAG = 1;
} else if( e.type == SDL_MOUSEBUTTONDOWN ) {
xyy_debug2
} else if( e.type == SDL_MOUSEBUTTONUP ) {
xyy_debug3
} else if( e.type == SDL_MOUSEMOTION ) {
xyy_debug1
} else if( e.type == SDL_KEYDOWN ) {
xyy_debug4
switch( e.key.keysym.sym )
{
case SDLK_ESCAPE:
appFLAG=1;
break;
case SDLK_0:
break;
case SDLK_1:
printf(" key1 - x\n");
break;
case SDLK_2:
printf(" key2 - display \n");
break;
case SDLK_3:
printf(" key3 - display \n");
break;
case SDLK_4:
printf(" key4 - display \n");
break;
case SDLK_LEFT:
std::cout << "man1@(" << man1.x << "," << man1.y << ")\n";
man1.tele(-5,0);
SDL_UpdateWindowSurface( wind.xWindow );
break;
case SDLK_RIGHT:
std::cout << "man1@(" << man1.x << "," << man1.y << ")\n";
man1.tele(+5,0);
SDL_UpdateWindowSurface( wind.xWindow );
break;
case SDLK_UP:
std::cout << "man1@(" << man1.x << "," << man1.y << ")\n";
man1.tele(0,-5);
SDL_UpdateWindowSurface( wind.xWindow );
break;
case SDLK_DOWN:
std::cout << "man1@(" << man1.x << "," << man1.y << ")\n";
man1.tele(0,+5);
SDL_UpdateWindowSurface( wind.xWindow );
break;
default:
break;
}
}
}
}
SDL_Quit();
return 0;
}
// should use a union...
void fDEBUG(int i, int a1=0, int a2=0, int a3=0, int a4=0)
{
if(i==1) {
std::cout << "(" << a1 << "," << a2 << ") ";
} else {
}
}
/*
// === work on getting this working \/
//Fill the surface white
SDL_Rect r1; r1.x=0; r1.y=0; r1.w=32; r1.h=32;
const SDL_Rect *r2 = &r1;
SDL_FillRect( wind.xSurface, r2, SDL_MapRGB( (wind.xSurface)->format, 0x99, 0x66, 0x44 ) );
SDL_Delay( 1000 );
SDL_FillRect( this->xSurface, NULL, SDL_MapRGB( this->xSurface->format, 0x34, 0x50, 0xFF ) );
SDL_Delay(1000);
//fill rect
SDL_FillRect( wind.xSurface, rs, SDL_MapRGB( wind.xSurface->format, 0xFF, 0xFF, 0xFF ) );
SDL_UpdateWindowSurface( wind.xWindow );
*/