I took a year of Java in college, but it was mostly academic/business-oriented coding. I am trying to make my first game, and I am at the point of having 2D graphics working in Swing and a character I can move back and forth, but I am having problems with ‘jumping’. Intending to make a 2D platformer, it is integral that I figure out vertical movement. As it stands I am using a KeyListener on my canvas to move the Entity object I have created, but my control scheme seems to be very primitive. I can make the Entity move left or right or jump, but it is unable to ‘jump’ and move a direction at the same time. I am using a switch statement to control the movement as such:
public void movement(KeyEvent e) {
switch(e.getKeyCode()) {
case KeyEvent.VK_RIGHT:
if(myX >= 940) {
break;
}
myX += 10;
break;
case KeyEvent.VK_LEFT:
if(myX <= 10) {
break;
}
myX -= 10;
break;
case KeyEvent.VK_SPACE:
while(myY < 400) {
myY += 20;
}
while(myY > 300) {
myY -= 20;
}
break;
}
}
What is the standard method of creating vertical/arcing movement of an Entity in 2D space? I apologize if this information is posted elsewhere, I couldn’t find it.
Thanks in advance,
boom_box