aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--include/UIClass.h1
-rw-r--r--src/UIClass.cpp23
-rw-r--r--src/main.cpp32
4 files changed, 23 insertions, 35 deletions
diff --git a/Makefile b/Makefile
index 66b1c7f..7b8b834 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
FLAGS_LINUX = -lGL -lSDL2_image -lfreetype
FLAGS_WIN32 = -lopengl32 -lmingw32 -lSDL2_Image -lfreetype
-FLAGS = -m32 -std=c++11 -Iinclude -Iinclude/freetype2 -Wall -Werror -Wextra -lSDL2main -lSDL2
+FLAGS = -m32 -std=c++11 -Iinclude -Iinclude/freetype2 -Wall -Werror -lSDL2main -lSDL2
all:
@g++ src/*.cpp -o main $(FLAGS_LINUX) $(FLAGS)
diff --git a/include/UIClass.h b/include/UIClass.h
index 867044e..ed07551 100644
--- a/include/UIClass.h
+++ b/include/UIClass.h
@@ -7,6 +7,7 @@
namespace ui {
extern int mousex,mousey;
+ extern bool debug;
void init(const char *ttf);
void setFontSize(unsigned int fs);
void putText(const float x,const float y,const char *s,...);
diff --git a/src/UIClass.cpp b/src/UIClass.cpp
index 94aa09c..eec7bec 100644
--- a/src/UIClass.cpp
+++ b/src/UIClass.cpp
@@ -1,5 +1,4 @@
#include <UIClass.h>
-
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -42,7 +41,7 @@ namespace ui {
std::cout<<"Error! Invalid character."<<std::endl;
return;
}
- glActiveTexture(GL_TEXTURE0);
+ //glActiveTexture(GL_TEXTURE0);
glGenTextures(1,&ftex);
glBindTexture(GL_TEXTURE_2D,ftex);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -134,14 +133,6 @@ namespace ui {
player.vel.y += .003;
}
}
- if(e.key.keysym.sym == SDLK_k){
- if(currentWorld->infront){
- player.loc.x+=(currentWorld->infront->getWidth()-currentWorld->getWidth())/2;
- memset(&player.vel,0,sizeof(vec2));
- currentWorld=currentWorld->infront;
- }
- }
- break;
if(e.key.keysym.sym == SDLK_i){
if(currentWorld->behind){
thing=(currentWorld->getWidth()-currentWorld->behind->getWidth())/2;
@@ -153,7 +144,13 @@ namespace ui {
}
}
}
- }
+ if(e.key.keysym.sym == SDLK_k){
+ if(currentWorld->infront){
+ player.loc.x+=(currentWorld->infront->getWidth()-currentWorld->getWidth())/2;
+ memset(&player.vel,0,sizeof(vec2));
+ currentWorld=currentWorld->infront;
+ }
+ }
if(e.key.keysym.sym == SDLK_F3){
debug = !debug;
}
@@ -164,11 +161,9 @@ namespace ui {
if(e.key.keysym.sym == SDLK_LSHIFT) player.speed = 1.0;
if(e.key.keysym.sym == SDLK_SPACE)
if(player.vel.y<=.001)space=false;
-
if(e.key.keysym.sym == SDLK_ESCAPE) gameRunning = false;
break;
}
}
-
}
-}
+} \ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index 3b525d5..73b1918 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -35,7 +35,7 @@ unsigned int millis(void){
return std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
}
-int main(/*int argc,char **argv*/){
+int main(int argc, char *argv[]){
//runs start-up procedures
if(!SDL_Init(SDL_INIT_VIDEO)){
atexit(SDL_Quit);
@@ -47,7 +47,7 @@ int main(/*int argc,char **argv*/){
//Turn on double Buffering
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//ANTIALIASING!!!
- SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16);
//create the window
window = SDL_CreateWindow("Independent Study v.0.2 alpha", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL
@@ -193,19 +193,19 @@ void render(){
**************************/
//DRAW MOUSE HERE!!!!!
- mx=(ui.mousex/(float)SCREEN_WIDTH)*2.0f-1.0f;
- my=((SCREEN_HEIGHT-ui.mousey)/(float)SCREEN_HEIGHT)*2.0f-1.0f;
+ mx=(ui::mousex/(float)SCREEN_WIDTH)*2.0f-1.0f;
+ my=((SCREEN_HEIGHT-ui::mousey)/(float)SCREEN_HEIGHT)*2.0f-1.0f;
if(player.loc.x-1>-1 && player.loc.x-1<-3+currentWorld->getWidth()){
- if(ui.debug)
- ui.putText(-.98 + player.loc.x, .94, "FPS: %1.0f\nDT: %1.0f",fps, d);
+ if(ui::debug)
+ ui::putText(-.98 + player.loc.x, .94, "FPS: %1.0f\nDT: %1.0f",fps, d);
mx+=player.loc.x;
}else if(player.loc.x-1>=-3+currentWorld->getWidth()){
- if(ui.debug)
- ui.putText(-.98 + -2+currentWorld->getWidth(), .94, "FPS: %1.0f\nDT: %1.0f",fps, d);
+ if(ui::debug)
+ ui::putText(-.98 + -2+currentWorld->getWidth(), .94, "FPS: %1.0f\nDT: %1.0f",fps, d);
mx =mx-1 + -1+currentWorld->getWidth();
}else{
- if(ui.debug)
- ui.putText(-.98, .94, "FPS: %1.0f\nDT: %1.0f",fps, d);
+ if(ui::debug)
+ ui::putText(-.98, .94, "FPS: %1.0f\nDT: %1.0f",fps, d);
}
glBegin(GL_TRIANGLES);
@@ -257,19 +257,11 @@ void logic(){
if((mx > entnpc[i]->loc.x && mx < entnpc[i]->loc.x + entnpc[i]->width) && (my > entnpc[i]->loc.y && my < entnpc[i]->loc.y + entnpc[i]->height)&&(SDL_GetMouseState(NULL,NULL) & SDL_BUTTON(SDL_BUTTON_LEFT))){
if(pow((entnpc[i]->loc.x - player.loc.x),2) + pow((entnpc[i]->loc.y - player.loc.y),2) < pow(.2,2)){
entnpc[i]->interact();
- ui.putText(entnpc[i]->loc.x, entnpc[i]->loc.y - HLINE * 3, "HEY", NULL);
+ ui::putText(entnpc[i]->loc.x, entnpc[i]->loc.y - HLINE * 3, "HEY", NULL);
}
}
-
- /*for(int i = 0; i < 32; i++){
- if(entnpc[i]->alive){
- currentWorld->detect(&entnpc[i]->loc,&entnpc[i]->vel,entnpc[i]->width);
- std::cout<<(void *)entnpc[i]<<" "<<i<<" "<<entnpc<<" "<<eAmt(entnpc)<<std::endl;
- entnpc[i]->wander(30, &entnpc[i]->vel);
-
}
- }
- */
+ }
tickCount++;
}