Ok, so I am making this platform game and I have my tilemap, walking and jumping animations. There is, however, one big problem. I am struggling to figure out how to implement collisionDetection. If anyone would like to help me and educate me on how to do this with the code I have, that would be AMAZING!
Hi
, I'm making a 2d sidescroller and my code, at the moment is all over the place. Currently, I am working on trying to get my jump animation to work when pressing the Up Key. I can't get it to animate correctly, and I am pressed for time for this project. I still haven't implemented collisionDetection, and I probably need help on that too. I think one way to do it would be to detect if there is a certain element below the player and if there is, etc..etc..but I can't figure out how to code it correctly if that is the case. If anyone is willing to help me, I would appreciate it. I want to learn, so if my code is extremely off or is terrible, please tell me how to improve it. The code and classes are posted below.
Level1 Class: int x,y;
int frame=0;
int frameY=0;
PImage bg;
TileMap map;
int scrollNum=0;
int scrollNumY=0;
String images[]= {"blank.gif","tree_1.gif","tree_2.gif","tree_3.gif",
"tree_4.gif","tree_5.gif","tree_6.gif","tree_7.gif","tree_8.gif",
"tree_9.gif","tree_10.gif","tree_11.gif","tree_12.gif","tree_13.gif",
"tree_14.gif","tree_15.gif","tree_16.gif","tree_17.gif","tree_18.gif",
"tree_19.gif","tree_20.gif","tree_21.gif","tree_22.gif","tree_23.gif",
"tree_24.gif","tree_25.gif","tree_26.gif","tree_27.gif","tree_28.gif",
"tree_29.gif","Platform1.png","platform2.png","platform3.png",
"tree_bush.gif","rock 1.png","rock2.png","rock3.png","rock6.png",
"bridge_1.png","bridge_2.png","bridge_3.png"};
I'm creating a side scrolling platform game, and the first step was to see if I could make the map. I have an array of integers to represent my tiles, and then I loop through my image array to load the actual images. Then, i would loop through the array to place each tile on the screen. I'm not sure why, but i keep get an arrayOutofBounds error, but I checked to make sure that the for loop was correct, and I'm not understanding the error. I posted the code below, except for the TileMap class and I am hoping someone can tell me what the problem is.