aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/world.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/world.cpp b/src/world.cpp
index d2a15f7..12d9591 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -61,13 +61,20 @@ void World::draw(vec2 *vec){
void World::detect(vec2 *v,vec2 *vel,const float width){
unsigned int i;
+ // Vertical checks
i=(v->x+width/2-x_start)/HLINE;
if(v->y<=line[i].y){
vel->y=0;
v->y=line[i].y+HLINE/2;
- return;
}else{
vel->y-=.05;
- return;
+ }
+ // Horizontal checks
+ if(v->x<x_start){
+ vel->x=0;
+ v->x=x_start+HLINE/2;
+ }else if(v->x>x_start+getWidth()){
+ vel->x=0;
+ v->x=x_start+getWidth()-width-HLINE/2;
}
}