Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Week1ProjectCS242
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sgupta72
Week1ProjectCS242
Commits
fbdb5f07
Commit
fbdb5f07
authored
7 years ago
by
sgupta72
Browse files
Options
Downloads
Patches
Plain Diff
Working
parent
50fec9e2
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
game.h
+6
-1
6 additions, 1 deletion
game.h
rect.h
+47
-1
47 additions, 1 deletion
rect.h
rubric
+13
-0
13 additions, 0 deletions
rubric
window.h
+2
-0
2 additions, 0 deletions
window.h
with
68 additions
and
2 deletions
game.h
+
6
−
1
View file @
fbdb5f07
...
...
@@ -2,15 +2,20 @@
#define GAME_H
#include
<SDL2/SDL.h>
/**
* Main game class that contains game loop
**/
class
Game
{
public:
Game
();
~
Game
();
//main game loop
void
GameLoop
();
private:
//has the user quit?
bool
quit
;
//current event
SDL_Event
e
;
};
#endif
This diff is collapsed.
Click to expand it.
rect.h
+
47
−
1
View file @
fbdb5f07
...
...
@@ -14,19 +14,65 @@ class Window;
class
Rect
{
public:
/**
* load spritesheet
* filename: filaname of image file
* window: window to draw on
**/
Rect
(
string
filename
,
Window
&
window
);
//load spritesheet
/**
* load spritesheet
* filename: filaname of image file
* window: window to draw on
* rows: rows in spritesheet
* column: columns in spritesheet
**/
Rect
(
string
filename
,
Window
&
window
,
int
rows
,
int
columns
);
~
Rect
();
/**
* move rect to x, y coordinate
**/
void
Move
(
int
x
,
int
y
);
/**
* add velocity to movement
**/
void
AddVelocity
(
int
vx
,
int
vy
);
/**
* update position of rect
**/
void
UpdatePosition
();
/**
* draw the image
* window: window to draw on
**/
void
Draw
(
Window
&
window
);
/**
* render part of spritesheet on window
* window: window to draw on
* row: row of spritesheet
* column: column of spritesheet
**/
void
Draw
(
Window
&
window
,
int
row
,
int
column
);
/**
* check collision with rect
* rect: rectangle ot check against
**/
bool
CheckCollision
(
Rect
&
rect
);
/**
* move back if colliding with rect in rects
* rects: rect vector to check against
**/
void
CorrectPosition
(
vector
<
Rect
*>
rects
);
/**
* get image surface
**/
SDL_Surface
*
get_image
();
private:
/**
* actually load image
* filename: file to load from
* window: window to draw on
*/
void
LoadImage
(
string
filename
,
Window
&
window
);
SDL_Surface
*
image
;
int
x
,
y
;
...
...
This diff is collapsed.
Click to expand it.
rubric
0 → 100644
+
13
−
0
View file @
fbdb5f07
Main game logic.
Player movement:
Player should be able to move around and jump.
Enemy spawning and movement:
Enemy should spawn and move around automatically.
Enemy Killing and respawning
Should be able to kill enemy. Enemy should respawn after killing.
Animation:
Player and enemy should be animated.
This diff is collapsed.
Click to expand it.
window.h
+
2
−
0
View file @
fbdb5f07
...
...
@@ -11,7 +11,9 @@ class Window
public:
Window
();
~
Window
();
//get screen surface to draw on, etc.
SDL_Surface
*
get_screen_surface
();
//update window
void
Update
();
private:
SDL_Window
*
window
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment