Skip to content

Commit

Permalink
Tonights progress desu
Browse files Browse the repository at this point in the history
  • Loading branch information
Taniz committed Nov 28, 2013
1 parent 7099890 commit 6410373
Show file tree
Hide file tree
Showing 13 changed files with 658 additions and 75 deletions.
18 changes: 9 additions & 9 deletions Laamapeli/Data/Config/Settings.ini
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[Display]
Width = 1600
Height = 900
Width = 1280
Height = 720
FPS = 120


[Audio]
Volume = 50
Pan = -0.000000
Pan = 0.0


; Don't change these if you down't want to mess with gameplay
[Game]
upTime = 1
upSpeed = 0.01
downSpeed = 0.5;
scoreTime = 0.2;
speedScore = 100;
startSpeed = 2;
upTime = 30
upSpeed = 0.02
downSpeed = 0.025
scoreTime = 0.2
speedScore = 100
startSpeed = 2
9 changes: 2 additions & 7 deletions Laamapeli/Draw.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef drawDEF
#define drawDEF

string round(float);

class Draw{
private:
Expand Down Expand Up @@ -58,12 +59,6 @@ inline void Draw::player(int x, int y){
}

inline void Draw::ground(int x, int y){
int x1 = x - 100;
int y1 = y;

int x2 = x + 100;
int y2 = y;

al_draw_bitmap(groundpic, x, y, NULL);
}

Expand Down Expand Up @@ -116,7 +111,7 @@ inline void Draw::menu(int menu, int selection, int WIDTH, int HEIGHT, int FPS,
}
case(4):{
text1 = "Volume: " + to_string(Volume);
text2 = "Pan: " + to_string(Pan);
text2 = "Pan: " + round(Pan);
text3 = "Back";
break;
}
Expand Down
45 changes: 40 additions & 5 deletions Laamapeli/Events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ float scoreTime;
int speedScore;
int startSpeed;
int resPos;
int lastX;
int lastY;

float tempPan;
int tempFPS;
Expand All @@ -37,6 +39,8 @@ bool timerEvent(ALLEGRO_EVENT);
void startTimer(int);
int initialize();
void destroy();
void groundVectorDestroy();
string round(float);


void iniWrite(string, string, string);
Expand Down Expand Up @@ -69,6 +73,24 @@ bool keyPressEvent(ALLEGRO_EVENT ev){
if(ev.type == ALLEGRO_EVENT_KEY_DOWN){
switch(ev.keyboard.keycode){

// SPACE button
case ALLEGRO_KEY_ESCAPE:{
if (gamePos == 3){
gamePos = 1;
groundVectorDestroy();
}
if(gamePos == 1)
if(menuText == 1)
temp = true;
else
if(menuText != 4)
menuText -= 1;
else
menuText = 2;

break;
}

// SPACE button
case ALLEGRO_KEY_SPACE:{
audio->jump(Volume, Pan);
Expand All @@ -85,6 +107,7 @@ bool keyPressEvent(ALLEGRO_EVENT ev){
switch (menuSelect){
case(1):{
gamePos = 2;
menuSelect = 0;
break;
}
case(2):{
Expand Down Expand Up @@ -151,7 +174,7 @@ bool keyPressEvent(ALLEGRO_EVENT ev){
break;
}
case(2):{
iniWrite("Audio", "Pan", to_string(tempPan));
iniWrite("Audio", "Pan", round(tempPan));
destroy();
initialize();
break;
Expand All @@ -169,6 +192,7 @@ bool keyPressEvent(ALLEGRO_EVENT ev){
}
case(4):{
gamePos = 1;
groundVectorDestroy();
break;
}
}
Expand Down Expand Up @@ -296,10 +320,10 @@ void drawEvent(){
case(2):{
gamePos = 3;

player->start(startSpeed);
player->start(startSpeed, WIDTH, HEIGHT);

ground = new Ground(HEIGHT);
ground->start(WIDTH, HEIGHT, draw->picHeight());
ground->start(WIDTH, HEIGHT, draw->picHeight(), &lastX, &lastY);
groundVector.push_back(*ground);
delete ground;

Expand All @@ -310,8 +334,8 @@ void drawEvent(){
delete ground;
}

for (it = groundVector.begin() + 1; it != groundVector.end(); it++){
it->create(prev(it)->getX(), prev(it)->getY());
for (it = groundVector.begin(); it != groundVector.end(); it++){
it->create(&lastX, &lastY);
}

startTimer(0);
Expand All @@ -337,9 +361,20 @@ void drawEvent(){
// Update all ground positions and draw them to backbuffer
player->setGround(false);

int tempX = player->getX();
int tempY = player->getY();
int tempH = draw->picHeight();
int tempW = draw->picWidth();
player->setGround(false);
// Draw grounds to screen
for (it = groundVector.begin(); it != groundVector.end(); it++){
draw->ground(it->getX(), it->getY());
if(it->getX() - 300 <= (tempX - tempW*1.5) && it->getX() + 300 - tempW/2 >= (tempX))
if(it->getY() == (tempY + tempH))
player->setGround(true);

if (it->getX() + 300 <= 0)
it->create(&lastX, &lastY);
}

// draw player and text to backbuffer
Expand Down
Loading

0 comments on commit 6410373

Please sign in to comment.