Exfoliate
YaBB Newbies
Offline
Posts: 3
Ironing out problems with simple game
Mar 28th , 2008, 1:51am
Hey guys, sorry if this is in the wrong section, wasn't really sure. Some friends and I are trying to make a simple side scroller, hopefully in the end you'll be able to jump, shoot, morph into other characters, upgrade attributes, that kind of thing. There will also have to be some basic form of enemy ai involved too. However we'll deal with those problems as we see fit, for right now we're a little stuck on the jumping. In this early build used for testing stuff the guy (dot) can jump up and technically can jump left or right but it's very awkward. Ideally we want to be able to have the character be able to run and then press the jump button and be able to move in the direction. If you could play what there is of the game you'll immediately see the issue, but you can't attach files I guess so you'll just have to base it off of the raw code. Any tips, suggestions, or code would be greatly appreciated. int $x = 0; int $jump = 0; int $dx = 30; int $dy = 61; PImage img; PImage img1; PImage img2; void setup(){ size (100, 100); img = loadImage ("test1.jpg");//level one img1 = loadImage ("dots.jpg");//dot or character img2 = loadImage ("test2.jpg");//level 2 } void draw() { image (img, $x, 0); image (img1, $dx, $dy); if ((keyPressed == true) && (key == 'd')){//move right and falling $x --; $dy ++; }else if ((keyPressed == true) && (key == 'a')){//move left and falling $x ++; $dy ++; }else if ((keyPressed == true) && (key == 'w')){//jump if ($jump <= 3){ $dy = $dy - 2; $jump ++; if ($jump > 5){ $dy = $dy + 2; } } }else if ((keyPressed == true) && (key == 's')){//move down does do anything $dy ++; }else $dy ++; $jump = 0; image (img1, $dx, $dy); if ($dy >= 62){//floor boundary $dy = 61; } if ($dy <= 0){//top boundary $dy = 1; } if ($x>=1){//left side boundary $x=0; } if($x <= -988){//to go to new level img = img2; $dy=61; $dx=30; $x=0; } if (($x <= -132)&&($x >= -230)&&($dy >= 35)){//top of box 1 $dy = 34; } if (($x == -131)&&($dy >= 35)){//left side box 1 $x ++; } if (($x == -231)&&($dy >= 35)){//right side box 1 $x --; } if (($x <= -268)&&($x >= -366)&&($dy >= 49)){//top of box 2 $dy = 48; } if (($x == -267)&&($dy >= 55)){//left side box 2 $x ++; } if (($x == -367)&&($dy >= 55)){//right side box 2 $x --; } }