java - Slick2D TiLED Collision Detection with Tiles -


i have piece of code:

for(int i=0; i<map.map.getobjectcount(1); i++){     if(cons.player.intersects(map.map.gettile)) {     //do something..     } } 

what trying check if rectangle have player intersects tile in map property "blocked" "true". how woud can set boolean true? also, how stop player moving in direction if tiles wants move has blocked property? here movement code:

        // input     input = container.getinput();     //     if (input.iskeydown(input.key_w) || input.iskeydown(input.key_up)) {         if (input.iskeydown(input.key_lshift)) {             shifty += delta * cons.p_sprint_speed;         } else {             shifty += delta * cons.p_speed;         }         cons.p_direction = "up";      }     // down     if (input.iskeydown(input.key_s) || input.iskeydown(input.key_down)) {         if (input.iskeydown(input.key_lshift)) {             shifty -= delta * cons.p_sprint_speed;         } else {             shifty -= delta * cons.p_speed;         }         cons.p_direction = "down";      }      // left     if (input.iskeydown(input.key_a) || input.iskeydown(input.key_left)) {         if (input.iskeydown(input.key_lshift)) {             shiftx += delta * cons.p_sprint_speed;         } else {             shiftx += delta * cons.p_speed;         }         cons.p_direction = "left";     }      // right     if (input.iskeydown(input.key_d) || input.iskeydown(input.key_right)) {         if (input.iskeydown(input.key_lshift)) {             shiftx -= delta * cons.p_sprint_speed;         } else {             shiftx -= delta * cons.p_speed;         }         cons.p_direction = "right";     } 

thanks


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -