Jump to content
  • Advertisement

TylerHum

Member
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

100 Neutral

About TylerHum

  • Rank
    Newbie
  1. TylerHum

    Random Level Builder Help

    [s] Ah I've discovered the source of the issue! My only issue now is that I don't know how to actually fix it. CollisionCheck snippet: for(int y=x1; y<y2; y++) { for(int x=x1; x<x2; x++) { if(LevelCurrent[x][y].walkable==1) return false; } } return true; The issue is that since the halls are 1 tile in width whenever it goes through y<y2 or x<x2 its equal to it so it just passes by without being checked. y=y1; x=x1; while(y<=y2) { while(x<=x2) { if(LevelCurrent[x][y].walkable==1) return false; x++; } y++; } return true; ^ I tried doing this so it wouldnt just pass on and the only thing it would do after that was build halls straight up for some odd reason. [/s]Ya know what disregard all of that I completely forgot about do while loops and it's now working perfectly. Thank you all for your help.
  2. TylerHum

    Random Level Builder Help

    Ok I got the issues with the checking function (Thanks Lorenzo) and they now work fine with building the rooms but the hallways still build over everything as if nothing is there. Here's how it does hallways moving up. All the other hall builders are basically the same as this. if((LevelCurrent[x][y].flag_build==1||LevelCurrent[x][y].flag_build==2)&&type==0) { length=rand()%10; while(!cont||y-length<4||!CollisionCheck(LevelCurrent,x,y-length,x,y)) { length--; if(length<=4) cont=true; } if(length>4&&y>4&&LevelCurrent[x][y].direction!=2) { for(int i=0; i<length; i++) { LevelCurrent[x][y-i].walkable=1; } LevelCurrent[x][y].flag_build=0; LevelCurrent[x][y-length].flag_build=1; LevelCurrent[x][y-length].tries=5; LevelCurrent[x][y-length].direction=0; } else { if(LevelCurrent[x][y].tries>0) LevelCurrent[x][y].tries--; else if(LevelCurrent[x][y].tries==0) LevelCurrent[x][y].flag_build=0; } } I'm starting to think I'm doing halls all wrong to be honest. Any input would be great. Edit: Also if I set the compiler to Release instead of Debug (MS VC++ 2010) and set a break in the collision check function it claims it will never be hit.
  3. TylerHum

    Random Level Builder Help

    Yea I've debugged if for a few hours now and I still cant find the issue.
  4. Ok I'm trying to make a Level builder that'll build rooms and halls but its become rather hit and miss and I'm stuck on it. For one the checker that makes sure it wont build over itself only fires when it wants it seems and two it can go from putting completely random garbage all over to getting stuck in infinite loops. Build Level: #include "BL.h" bool CollisionCheck(Tile LevelCurrent[100][100],int x,int y,int width,int height) { int check=0; bool fin; for(y; y<height; y++) { for(x; x<width; x++) { if(LevelCurrent[x][y].walkable==1) check++; } } if(check>0) fin=false; else if(check==0) fin=true; return fin; } void BuildLevel(Tile LevelCurrent[100][100],int stair_x,int stair_y) { bool finish=false,cont=false; int x,y,x2,y2,type,length,roll,counter; type=4; for(y=0; y<100; y++) { for(x=0; x<100; x++) { LevelCurrent[x][y].walkable=0; LevelCurrent[x][y].flag_build=0; LevelCurrent[x][y].tries=0; } } LevelCurrent[stair_x][stair_y].flag_build=1; LevelCurrent[stair_x][stair_y].tries=5; while(!finish) { /* TYPES: Halls= 0-3 Standard Rooms= 4-24 Uncommon Rooms= 25-45 Rare Rooms= 46-66 */ type=rand()%5; for(y=0; y<100; y++) { for(x=0; x<100; x++) { //===========HALLS============================================================================================// //===UpHall============// if((LevelCurrent[x][y].flag_build==1||LevelCurrent[x][y].flag_build==2)&&type==0) { length=rand()%20; while(!CollisionCheck(LevelCurrent,x,y-length,1,length)&&y-length>4) { if(length<=4) break; length--; } if(length>4) { for(int i=0; i<length; i++) { LevelCurrent[x][y-i].walkable=1; } LevelCurrent[x][y].flag_build=0; LevelCurrent[x][y-length].flag_build=1; } else{ if(LevelCurrent[x][y].tries>0) LevelCurrent[x][y].tries++; else LevelCurrent[x][y].flag_build=0; } } //=====================// //===RightHall=========// if((LevelCurrent[x][y].flag_build==2)&&type==1) { length=rand()%20; while(!CollisionCheck(LevelCurrent,x,y,length,1)&&x+length<92) { if(length<=4) break; length--; } if(length>4) { for(int i=0; i<length; i++) { LevelCurrent[x+i][y].walkable=1; } LevelCurrent[x][y].flag_build=0; LevelCurrent[x+length][y].flag_build=1; } else{ if(LevelCurrent[x][y].tries>0) LevelCurrent[x][y].tries++; else LevelCurrent[x][y].flag_build=0; } } //=====================// //===DownHall==========// if((LevelCurrent[x][y].flag_build==2)&&type==2) { length=rand()%20; while(!CollisionCheck(LevelCurrent,x,y,1,length)&&y+length<92) { if(length<=4) break; length--; } if(length>4) { for(int i=0; i<length; i++) { LevelCurrent[x][y+i].walkable=1; } LevelCurrent[x][y].flag_build==0; LevelCurrent[x][y+length].flag_build=1; } else{ if(LevelCurrent[x][y].tries>0) LevelCurrent[x][y].tries++; else LevelCurrent[x][y].flag_build=0; } } //=====================// //===LeftHall==========// if((LevelCurrent[x][y].flag_build==2)&&type==3) { length=rand()%20; while(!CollisionCheck(LevelCurrent,x-length,y,length,1)&&x-length>4) { if(length<=4) break; length--; } if(length>4) { for(int i=0; i<length; i++) { LevelCurrent[x-1][y].walkable=1; } LevelCurrent[x][y].flag_build=0; LevelCurrent[x-length][y].flag_build=1; } else{ if(LevelCurrent[x][y].tries>0) LevelCurrent[x][y].tries++; else LevelCurrent[x][y].flag_build=0; } } //=====================// //============================================================================================================// //===========COMMON_ROOMS=====================================================================================// //Diamond - Medium - Type 4 if(LevelCurrent[x][y].flag_build==1&&type==4) { if(CollisionCheck(LevelCurrent,x-3,y-3,7,7)) { //=Y-3========================// LevelCurrent[x][y-3].walkable=1; //============================// //=Y-2========================// LevelCurrent[x-1][y-2].walkable=1; LevelCurrent[x][y-2].walkable=1; LevelCurrent[x+1][y-2].walkable=1; //============================// //=Y-1========================// LevelCurrent[x-2][y-1].walkable=1; LevelCurrent[x-1][y-1].walkable=1; LevelCurrent[x][y-1].walkable=1; LevelCurrent[x+1][y-1].walkable=1; LevelCurrent[x+2][y-1].walkable=1; //============================// //=Y+0========================// LevelCurrent[x-3][y].walkable=1; LevelCurrent[x-2][y].walkable=1; LevelCurrent[x-1][y].walkable=1; LevelCurrent[x][y].walkable=1; LevelCurrent[x+1][y].walkable=1; LevelCurrent[x+2][y].walkable=1; LevelCurrent[x+3][y].walkable=1; //============================// //=Y+1========================// LevelCurrent[x-2][y+1].walkable=1; LevelCurrent[x-1][y+1].walkable=1; LevelCurrent[x][y+1].walkable=1; LevelCurrent[x+1][y+1].walkable=1; LevelCurrent[x+2][y+1].walkable=1; //============================// //=Y+2========================// LevelCurrent[x-1][y+2].walkable=1; LevelCurrent[x][y+2].walkable=1; LevelCurrent[x+1][y+2].walkable=1; //============================// //=Y+3========================// LevelCurrent[x][y+3].walkable=1; //============================// //=Flags======================// if(LevelCurrent[x][y+4].walkable==0&&y+4<92) LevelCurrent[x][y+3].flag_build=2; if(LevelCurrent[x][y-4].walkable==0&&y-4>4) LevelCurrent[x][y-3].flag_build=2; if(LevelCurrent[x+4][y].walkable==0&&x+4<92) LevelCurrent[x+3][y].flag_build=2; if(LevelCurrent[x-4][y].walkable==0&&x-4>4) LevelCurrent[x-3][y].flag_build=2; //============================// //=Tries======================// if(LevelCurrent[x][y+4].walkable==0&&y+4<92) LevelCurrent[x][y+3].tries=5; if(LevelCurrent[x][y-4].walkable==0&&y-4>4) LevelCurrent[x][y-3].tries=5; if(LevelCurrent[x+4][y].walkable==0&&x+4<92) LevelCurrent[x+3][y].tries=5; if(LevelCurrent[x-4][y].walkable==0&&x-4>4) LevelCurrent[x-3][y].tries=5; //============================// LevelCurrent[x][y].tries=0; } /*else{ if(LevelCurrent[x][y].tries>0) LevelCurrent[x][y].tries++; else LevelCurrent[x][y].flag_build=0; }*/ } //============================================================================================================// //===========RARE_ROOMS=======================================================================================// //Hall Of Heroes - Type 46 if(type==46) { } //============================================================================================================// } } counter=0; for(y2=0; y2<100; y2++) { for(x2=0; x2<100; x2++) { if(LevelCurrent[x2][y2].flag_build!=0) counter++; } } if(counter==0) finish=true; counter=0; } return; } I'm at a complete lose at this point so any help would be greatly appreciated. Thanks.
  5. TylerHum

    2d scrolling and collision

    Awesome it finally works. Thank you for your help sir.
  6. TylerHum

    2d scrolling and collision

    I check at y-2 because he moves at a rate of 2 pixels normally. I had changed it just to check a few things. Tiles have a walkable integer. if its 1 you can walk on it 0 you cant. Key flags are checked per frame. Here's the full code if that helps any: Main.cpp #include "BL.h" extern void BuildLevel(Tile LevelCurrent[20][20]); const float FPS = 60; const int SCREEN_W = 640; const int SCREEN_H = 672; const int bizzle_SIZE = 32; enum MYKEYS { KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, MOUSE_1 }; enum BUTTONS { B1,B2,B3,B4,B5,B6,B7,B8,B9,B0,CHARA,INV,SAVE,LOAD,NEW,EXIT }; int main(int argc, char **argv) { ALLEGRO_DISPLAY *display = NULL; ALLEGRO_EVENT_QUEUE *event_queue = NULL; ALLEGRO_TIMER *timer = NULL; ALLEGRO_BITMAP *bizzle_spr = NULL; ALLEGRO_BITMAP *healthbar = NULL; ALLEGRO_BITMAP *manabar = NULL; ALLEGRO_BITMAP *expbar = NULL; ALLEGRO_BITMAP *wall = NULL; ALLEGRO_BITMAP *background = NULL; ALLEGRO_BITMAP *buffer = NULL; ALLEGRO_BITMAP *FlyCan = NULL; ALLEGRO_BITMAP *Textbox = NULL; ALLEGRO_BITMAP *Buttons = NULL; ALLEGRO_BITMAP *Logo = NULL; ALLEGRO_BITMAP *Map = NULL; ALLEGRO_FONT *font = NULL; //Bizzle's stats// Bizzle bizzle; char *hpC=new char[5]; char *mpC=new char[5]; char *xpC=new char[2]; char *strC=new char[5]; char *dexC=new char[5]; char *lodmgC=new char[5]; char *hidmgC=new char[5]; char *intelC=new char[5]; char *conC=new char[5]; char *defC=new char[5]; char *statsC=new char[5]; char *fireC=new char[5]; char *waterC=new char[5]; char *windC=new char[5]; char *earthC=new char[5]; //==DEBUGGY!===================// char *debugx=new char[5]; char *debugy=new char[5]; char *debugofflevelx=new char[5]; char *debugofflevely=new char[5]; char *debugwalk=new char[5]; //============================// //=============// //Level stuff// int levelnum; Tile levelCurrent[20][20]; Enemy *enemy = new Enemy[200]; std::vector<Item> item; //========// bool key[5] = { false, false, false, false,false }; bool buttons[16] = {false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false}; bool redraw = true; bool doexit = false; bool makelevelCurrent = false; bool turn=true; int wait = 0; int direction=0; int x=0,y=0,levelx=0,levely=0; int a,b,c; int d=0; int onlevel=1; int view=1;//view: 1=Main menu, 2=Game, 3=Inventory, 4=Character sheet, 5=Pause, 6=Spellbook float mouse_y,mouse_x; sprintf(xpC,"%d",bizzle.xp); a=b=c=0; al_init(); al_install_keyboard(); al_install_mouse(); al_init_image_addon(); al_init_font_addon(); al_init_ttf_addon(); timer = al_create_timer(1.0 / FPS); display = al_create_display(SCREEN_W, SCREEN_H); //bitmap creation healthbar = al_create_bitmap(100,10); manabar = al_create_bitmap(100,10); expbar = al_create_bitmap(100,10); buffer = al_create_bitmap(SCREEN_W,SCREEN_H); Textbox = al_create_bitmap(SCREEN_W,64); Map = al_create_bitmap(40,40); //bitmap loading bizzle_spr = al_load_bitmap("bizzle.png"); wall = al_load_bitmap("wall.bmp"); background = al_load_bitmap("background.bmp"); FlyCan = al_load_bitmap("flycan.bmp"); Buttons = al_load_bitmap("button_sheet.png"); Logo = al_load_bitmap("Logo.png"); //font loading font = al_load_font("courbd.ttf",12,0); al_set_target_bitmap(healthbar); al_clear_to_color(al_map_rgb(255,0,0)); al_set_target_bitmap(manabar); al_clear_to_color(al_map_rgb(0,0,255)); al_set_target_bitmap(expbar); al_clear_to_color(al_map_rgb(0,255,0)); al_set_target_bitmap(Textbox); al_clear_to_color(al_map_rgb(255,255,255)); al_set_target_bitmap(Map); al_clear_to_color(al_map_rgb(127,0,127)); al_set_target_bitmap(buffer); event_queue = al_create_event_queue(); al_register_event_source(event_queue, al_get_display_event_source(display)); al_register_event_source(event_queue, al_get_timer_event_source(timer)); al_register_event_source(event_queue, al_get_keyboard_event_source()); al_register_event_source(event_queue, al_get_mouse_event_source()); al_clear_to_color(al_map_rgb(255,255,255)); al_flip_display(); al_start_timer(timer); while(!doexit) { ALLEGRO_EVENT ev; al_wait_for_event(event_queue, &ev); if(ev.type == ALLEGRO_EVENT_TIMER) { //++++++++Main Menu++(View 1)+++++++++++++++++++++++++++++++++++++++++++++++++++// if(view==1){ if(buttons[NEW]||makelevelCurrent){ BuildLevel(levelCurrent); a=0; makelevelCurrent = false; view=2; } if(key[MOUSE_1]&& mouse_x<350&& mouse_x>290&& mouse_y<336&& mouse_y>316) { buttons[NEW]=true; } else buttons[NEW]=false; if(key[MOUSE_1]&& mouse_x<350&& mouse_x>290&& mouse_y<386&& mouse_y>356) { buttons[EXIT]=true; } else buttons[EXIT]=false; if(buttons[EXIT]) { doexit=true; } } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //++++++++Game++(View 2)+++++++++++++++++++++++++++++++++++++++++++++++++++// if(view==2){ //+++Key_UP++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// if(key[KEY_UP]) { if(levelCurrent[x/32][(y-2)/32].walkable==1 && levelCurrent[(x+(32-1))/32][(y-2)/32].walkable==1) { y-=2; } } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //+++Key_DOWN++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// if(key[KEY_DOWN]) { y+=2; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //+++Key_LEFT++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// if(key[KEY_LEFT]) { x-=2; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //+++Key_RIGHT+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// if(key[KEY_RIGHT]) { x+=2; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //+++Mouse_buttons+++++++++++++++++++++++++++++++++++++++++++++++++++++++// if(key[MOUSE_1]&& mouse_x<120&& mouse_x>100&& mouse_y<25&& mouse_y>5) { buttons[CHARA]=true; view=4; } else buttons[CHARA]=false; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// redraw = true; } else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { break; } else if(ev.type == ALLEGRO_EVENT_KEY_DOWN) { switch(ev.keyboard.keycode) { case ALLEGRO_KEY_UP: key[KEY_UP] = true; break; case ALLEGRO_KEY_DOWN: key[KEY_DOWN] = true; break; case ALLEGRO_KEY_LEFT: key[KEY_LEFT] = true; break; case ALLEGRO_KEY_RIGHT: key[KEY_RIGHT] = true; break; } } else if(ev.type == ALLEGRO_EVENT_KEY_UP) { switch(ev.keyboard.keycode) { case ALLEGRO_KEY_UP: key[KEY_UP] = false; break; case ALLEGRO_KEY_DOWN: key[KEY_DOWN] = false; break; case ALLEGRO_KEY_LEFT: key[KEY_LEFT] = false; break; case ALLEGRO_KEY_RIGHT: key[KEY_RIGHT] = false; break; case ALLEGRO_KEY_ESCAPE: doexit = true; break; } } else if(ev.type==ALLEGRO_EVENT_MOUSE_BUTTON_DOWN) { switch(ev.mouse.button){ case 1: key[MOUSE_1] = true; mouse_x=ev.mouse.x; mouse_y=ev.mouse.y; break; } } else if(ev.type==ALLEGRO_EVENT_MOUSE_BUTTON_UP) { switch(ev.mouse.button){ case 1: key[MOUSE_1] = false; break; } } if(redraw && al_is_event_queue_empty(event_queue)) { redraw = false; al_set_target_bitmap(buffer); al_clear_to_color(al_map_rgb(0,0,0)); //++++++++Main Menu++(View 1)++++++++++++++++++++++++++++++++++++++++++++++// if(view==1) { al_draw_bitmap(Logo,120,120,0); if(buttons[NEW]) al_draw_bitmap_region(Buttons,60,20,60,20,290,316,0); else al_draw_bitmap_region(Buttons,0,20,60,20,290,316,0); if(buttons[EXIT]) al_draw_bitmap_region(Buttons,60,60,60,20,290,356,0); else al_draw_bitmap_region(Buttons,0,60,60,20,290,356,0); } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //++++++++Game++(View 2)+++++++++++++++++++++++++++++++++++++++++++++++++++// if(view==2) { al_draw_bitmap(background,0,32,0); al_set_target_bitmap(Map); al_clear_to_color(al_map_rgb(0,0,127)); for(b=0;b<20;b++){ for(c=0;c<20;c++){ if(b+(y/32)<21&& b+(y/32)>-1&& c+(x/32)<21&& c+(x/32)>-1&& levelCurrent[c+(x/32)][b+(y/32)].walkable==1){ al_draw_pixel(c,b,al_map_rgb(0,127,255)); } } } al_set_target_bitmap(buffer); //draw levelCurrent chunk for(b=0;b<20;b++){ for(c=0;c<20;c++){ if(b+(y/32)<21&& b+(y/32)>-1&& c+(x/32)<21&& c+(x/32)>-1&& levelCurrent[c+(x/32)][b+(y/32)].walkable==1){ al_draw_bitmap(wall,(c*32)-x,(b*32)-y+32,0); } } } al_draw_bitmap(bizzle_spr, 320, 352, 0); al_draw_bitmap(healthbar,0,0,0); al_draw_bitmap(manabar,0,10,0); al_draw_bitmap(expbar,0,20,0); al_set_target_bitmap(Map); al_draw_pixel(20,20,al_map_rgb(127,255,127)); al_set_target_bitmap(buffer); //Button drawing// if(buttons[CHARA]) al_draw_bitmap_region(Buttons,80,0,20,20,100,5,0); else al_draw_bitmap_region(Buttons,20,0,20,20,100,5,0); //=============// al_draw_text(font,al_map_rgb(255,255,255),50,20,0,xpC); al_set_target_bitmap(buffer); al_draw_bitmap(Map,SCREEN_W-40,0,0); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //++++DEBUGGY!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// sprintf(debugx,"%d",x); sprintf(debugy,"%d",y); sprintf(debugofflevelx,"%d",x/32); sprintf(debugofflevely,"%d",y/32); sprintf(debugwalk,"%d",levelCurrent[x/32][(y-2)/32].walkable); al_draw_text(font,al_map_rgb(255,0,0),0,32,0,debugx); al_draw_text(font,al_map_rgb(255,0,0),0,52,0,debugy); al_draw_text(font,al_map_rgb(255,0,0),0,72,0,debugofflevelx); al_draw_text(font,al_map_rgb(255,0,0),0,92,0,debugofflevely); al_draw_text(font,al_map_rgb(255,0,0),0,112,0,debugwalk); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// al_set_target_bitmap(al_get_backbuffer(display)); al_draw_bitmap(buffer,0,0,0); al_flip_display(); } } al_destroy_bitmap(bizzle_spr); al_destroy_timer(timer); al_destroy_display(display); al_destroy_event_queue(event_queue); delete enemy; return 0; } BuildLevel.cpp #include "BL.h" void BuildLevel(Tile LevelCurrent[20][20]) { for(int i=0; i<20; i++) { for(int e=0; e<20; e++) { if(i>=8&&i<=12||e>=8&&e<=12) LevelCurrent[e].walkable=1; else if(i<8||i>12||e<8||e>12) LevelCurrent[e].walkable=0; LevelCurrent[e].Collision.x=e*32; LevelCurrent[e].Collision.y=i*32; LevelCurrent[e].Collision.height=32; LevelCurrent[e].Collision.width=32; } } return; } BL.h #ifndef __BL_H #define __BL_H #include <stdio.h> #include <vector> #include <fstream> #include <cmath> #include <ctime> #include <allegro5/allegro.h> #include <allegro5/allegro_image.h> #include <allegro5/allegro_font.h> #include <allegro5/allegro_ttf.h> struct Object{ unsigned int x, y; unsigned int width,height; }; struct Bizzle{ int hp,mp,xp; int str,dex,intel,con,def,stats; int fire,water,wind,earth; int abeast,afly,aundead,adragon,amagic,agiant,ahunger,aplant; int dbeast,dfly,dundead,ddragon,dmagic,dgiant,dhunger,dplant; int lodmg,hidmg; Object Collision; }; struct Enemy{ int hp,ap,name,graphic,xp,type1,type2,element; int x,y; bool moved; Object Collision; }; struct Item{ int type; //1=weapon,2=armor,3=consumable,4=parts int loDmg,hiDmg; //damage buffs int dex,str,con,intel,def; //stat buffs int Rdex,Rstr,Rcon,Rintel; //required stats for use int fire,water,earth,wind; //Weapons: element buffs | Armor: element resistance int beast,fly,undead,dragon,magic,giant,hunger,plant; //Weapons: type buffs | Armor: type resistance int hp,mp; int x,y; Object Collision; }; struct Tile{ Object Collision; unsigned short int walkable; }; #endif
  7. Ok I've started a 2d game that's supposed to scroll and as it scrolls it'll load the new bits of map, the issue I'm having with that is it's jumping. Everytime the character moves 32 pixels he jumps another 32 and centers on the next tile. My second issue is that the collision I have setup doesnt register ,it thinks every tile is a wall until Im off the map completely. I only setup the collision on the UP movement to test it otherwise I wouldnt be able to move at all. Weirdest part is the drawing function still see's the floors and draws them properly. Here is the code I have. I'm using C++ and Allegro 5: Movement: //+++Key_UP++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// if(key[KEY_UP]) { if(levelCurrent[x/32][(y-2)/32].walkable==1 && levelCurrent[(x+(32-1))/32][(y-2)/32].walkable==1) { y--; } } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //+++Key_DOWN++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// if(key[KEY_DOWN]) { y++; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //+++Key_LEFT++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// if(key[KEY_LEFT]) { x--; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //+++Key_RIGHT+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// if(key[KEY_RIGHT]) { x++; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //+++Mouse_buttons+++++++++++++++++++++++++++++++++++++++++++++++++++++++// if(key[MOUSE_1]&& mouse_x<120&& mouse_x>100&& mouse_y<25&& mouse_y>5) { buttons[CHARA]=true; view=4; } else buttons[CHARA]=false; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// Drawing: for(b=0;b<20;b++){ for(c=0;c<20;c++){ if(b+(y/32)<21&& b+(y/32)>-1&& c+(x/32)<21&& c+(x/32)>-1&& levelCurrent[c+(x/32)][b+(y/32)].walkable==1){ al_draw_bitmap(wall,(c*32)-x,(b*32)-y+32,0); } } } I'm pretty sure the issue is somewhere in there but I'm having a hard time finding a solution to it. Thanks for the help.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!