Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
imac-tower-defense
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas LIENART
imac-tower-defense
Commits
6d429186
Commit
6d429186
authored
Jun 06, 2019
by
Nicolas LIENART
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SD2 -> SDL1
parent
43998f42
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
39 additions
and
43 deletions
+39
-43
CMakeLists.txt
CMakeLists.txt
+4
-4
src/initmap/SDLConfig.c
src/initmap/SDLConfig.c
+9
-7
src/initmap/SDLConfig.h
src/initmap/SDLConfig.h
+3
-3
src/initmap/_main.c
src/initmap/_main.c
+8
-14
src/initmap/display.h
src/initmap/display.h
+2
-2
src/initmap/keyboard.c
src/initmap/keyboard.c
+1
-1
src/initmap/keyboard.h
src/initmap/keyboard.h
+1
-1
src/initmap/monster.h
src/initmap/monster.h
+1
-1
src/initmap/mouse.h
src/initmap/mouse.h
+1
-1
src/initmap/projectile.h
src/initmap/projectile.h
+1
-1
src/initmap/sound.h
src/initmap/sound.h
+2
-2
src/initmap/sprite.h
src/initmap/sprite.h
+1
-1
src/initmap/structures.h
src/initmap/structures.h
+3
-3
src/initmap/tour.h
src/initmap/tour.h
+2
-2
No files found.
CMakeLists.txt
View file @
6d429186
...
...
@@ -51,10 +51,10 @@ else()
target_link_libraries
(
${
PROJECT_NAME
}
m
SDL
2
SDL
2
_image
SDL
2
_mixer
SDL
2
_ttf
SDL
SDL_image
SDL_mixer
SDL_ttf
GL
GLU
)
...
...
src/initmap/SDLConfig.c
View file @
6d429186
...
...
@@ -8,12 +8,13 @@ void sdlConfig_initSDL() {
}
}
void
sdlConfig_reshape
(
SDL_
Window
**
surface
,
SDL_GLContext
*
GLcontext
,
unsigned
int
width
,
unsigned
int
height
)
void
sdlConfig_reshape
(
SDL_
Surface
**
surface
,
unsigned
int
width
,
unsigned
int
height
)
{
SDL_
Window
*
surface_temp
=
SDL_CreateWindow
(
WINDOW_TITLE
,
SDL_WINDOWPOS_CENTERED
,
SDL_WINDOWPOS_CENTERED
,
width
,
height
,
SDL_WINDOW_SHOWN
|
SDL_WINDOW
_OPENGL
);
SDL_
Surface
*
surface_temp
=
SDL_SetVideoMode
(
width
,
height
,
8
,
SDL
_OPENGL
);
SDL_ShowCursor
(
SDL_DISABLE
);
if
(
NULL
==
surface_temp
)
{
fprintf
(
stderr
,
"Erreur lors du redimensionnement de la fenetre.
\n
"
);
...
...
@@ -21,12 +22,13 @@ void sdlConfig_reshape(SDL_Window** surface, SDL_GLContext *GLcontext, unsigned
}
*
surface
=
surface_temp
;
int
window_width
,
window_height
;
SDL_GetWindowSize
(
*
surface
,
&
window_width
,
&
window_height
);
/*
if (*GLcontext == NULL) {
*GLcontext = SDL_GL_CreateContext(*surface);
}
*/
SDL_WM_SetCaption
(
WINDOW_TITLE
,
NULL
);
#ifdef _WIN32
if
(
glewInit
()
!=
0
)
...
...
@@ -36,8 +38,8 @@ void sdlConfig_reshape(SDL_Window** surface, SDL_GLContext *GLcontext, unsigned
}
#endif
glViewport
(
0
,
0
,
wi
ndow_width
,
window_
height
);
glViewport
(
0
,
0
,
wi
dth
,
height
);
glMatrixMode
(
GL_PROJECTION
);
glLoadIdentity
();
gluOrtho2D
(
1
,
wi
ndow_width
,
window_
height
,
1
);
gluOrtho2D
(
1
,
wi
dth
,
height
,
1
);
}
src/initmap/SDLConfig.h
View file @
6d429186
...
...
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <SDL
2
/SDL.h>
#include <SDL/SDL.h>
#include "cases.h"
#include "structures.h"
...
...
@@ -19,7 +19,7 @@
/* Dimensions initiales et titre de la fenetre */
static
const
unsigned
int
WINDOW_WIDTH
=
800
;
static
const
unsigned
int
WINDOW_HEIGHT
=
800
;
static
const
char
WINDOW_TITLE
[]
=
"
test
"
;
static
const
char
WINDOW_TITLE
[]
=
"
Insect Tower
"
;
/* Espace fenetre virtuelle */
static
const
float
GL_VIEW_WIDTH
=
200
.;
...
...
@@ -32,6 +32,6 @@ static const unsigned int BIT_PER_PIXEL = 32;
static
const
Uint32
FRAMERATE_MILLISECONDS
=
1000
/
60
;
void
sdlConfig_initSDL
();
void
sdlConfig_reshape
(
SDL_
Window
**
surface
,
SDL_GLContext
*
GLcontext
,
unsigned
int
width
,
unsigned
int
height
);
void
sdlConfig_reshape
(
SDL_
Surface
**
surface
,
unsigned
int
width
,
unsigned
int
height
);
#endif //SDLCONFIG_H_
src/initmap/_main.c
View file @
6d429186
#include <SDL
2
/SDL.h>
#include <SDL
2
/SDL_mixer.h>
#include <SDL
2
/SDL_image.h>
#include <SDL
2
/SDL_ttf.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_ttf.h>
#ifdef _WIN32
#include <GL/glew.h>
...
...
@@ -42,9 +42,8 @@ int main(int argc, char *argv[])
/* Définition de l'environnement SDL*/
sdlConfig_initSDL
();
SDL_Window
*
surface
;
SDL_GLContext
GLcontext
=
NULL
;
sdlConfig_reshape
(
&
surface
,
&
GLcontext
,
WINDOW_WIDTH
,
WINDOW_HEIGHT
);
SDL_Surface
*
surface
;
sdlConfig_reshape
(
&
surface
,
WINDOW_WIDTH
,
WINDOW_HEIGHT
);
SDL_GL_SetAttribute
(
SDL_GL_DOUBLEBUFFER
,
0
);
...
...
@@ -95,7 +94,7 @@ int main(int argc, char *argv[])
display_showCursor
();
/* Echange du front et du back buffer : mise a jour de la fenetre */
SDL_GL_Swap
Window
(
surface
);
SDL_GL_Swap
Buffers
(
);
SDL_Event
e
;
while
(
SDL_PollEvent
(
&
e
))
{
...
...
@@ -124,12 +123,6 @@ int main(int argc, char *argv[])
mouse_handleClick
();
break
;
case
SDL_WINDOWEVENT
:
if
(
e
.
window
.
event
==
SDL_WINDOWEVENT_RESIZED
)
{
sdlConfig_reshape
(
&
surface
,
&
GLcontext
,
e
.
window
.
data1
,
e
.
window
.
data2
);
}
break
;
case
SDL_KEYDOWN
:
keyboard_handleKeypress
(
&
e
);
default:
...
...
@@ -157,6 +150,7 @@ int main(int argc, char *argv[])
}
/* Liberation des ressources associees a la SDL */
SDL_FreeSurface
(
surface
);
Mix_CloseAudio
();
SDL_Quit
();
return
EXIT_SUCCESS
;
...
...
src/initmap/display.h
View file @
6d429186
...
...
@@ -14,8 +14,8 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <SDL
2
/SDL_ttf.h>
#include <SDL
2
/SDL.h>
#include <SDL/SDL_ttf.h>
#include <SDL/SDL.h>
#include "gui.h"
#include "structures.h"
...
...
src/initmap/keyboard.c
View file @
6d429186
...
...
@@ -2,7 +2,7 @@
void
keyboard_handleKeypress
(
SDL_Event
*
event
)
{
SDL
_Keycode
key
=
event
->
key
.
keysym
.
sym
;
SDL
Key
key
=
event
->
key
.
keysym
.
sym
;
if
(
gameData
->
gameState
==
LEVELPLAY
)
{
Etat
*
joueur
=
plateau
->
joueur
;
...
...
src/initmap/keyboard.h
View file @
6d429186
#ifndef KEYBAORD_H_
#define KEYBAORD_H_
#include <SDL
2
/SDL.h>
#include <SDL/SDL.h>
#include "structures.h"
#include "player.h"
...
...
src/initmap/monster.h
View file @
6d429186
...
...
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <SDL
2
/SDL_mixer.h>
#include <SDL/SDL_mixer.h>
#include "structures.h"
...
...
src/initmap/mouse.h
View file @
6d429186
...
...
@@ -7,7 +7,7 @@
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#include <SDL
2
/SDL.h>
#include <SDL/SDL.h>
#include "structures.h"
#include "cases.h"
...
...
src/initmap/projectile.h
View file @
6d429186
#ifndef PROJECTILE_H_
#define PROJECTILE_H_
#include <SDL
2
/SDL_mixer.h>
#include <SDL/SDL_mixer.h>
#include "structures.h"
#include "monster.h"
...
...
src/initmap/sound.h
View file @
6d429186
#ifndef SOUND_H_
#define SOUND_H_
#include <SDL
2
/SDL.h>
#include <SDL
2
/SDL_mixer.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <stdio.h>
#include "structures.h"
...
...
src/initmap/sprite.h
View file @
6d429186
...
...
@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <SDL
2
/SDL_image.h>
#include <SDL/SDL_image.h>
#include <string.h>
...
...
src/initmap/structures.h
View file @
6d429186
...
...
@@ -8,9 +8,9 @@
#include <GL/glu.h>
#endif
#include <SDL
2
/SDL.h>
#include <SDL
2
/SDL_mixer.h>
#include <SDL
2
/SDL_ttf.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_ttf.h>
typedef
enum
MapDataContent
{
MDATA_IMG
=
1
,
...
...
src/initmap/tour.h
View file @
6d429186
...
...
@@ -2,11 +2,11 @@
#define TOUR_H_
#pragma once
#include <SDL
2
/SDL_mixer.h>
#include <SDL/SDL_mixer.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <SDL
2
/SDL.h>
#include <SDL/SDL.h>
#include "structures.h"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment