-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharacter.java
More file actions
86 lines (76 loc) · 3.12 KB
/
Copy pathcharacter.java
File metadata and controls
86 lines (76 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import java.awt.event.*;
import javax.swing.*;
public class character extends JPanel implements KeyListener
{
GamePanel gamePanel = new GamePanel();
public static lava lavaCollison = GamePanel.lava;
public static void playerMovement(boolean moveLeft, boolean moveRight)
{
if(moveLeft == true)
{
GamePanel.playerPositionX -= GamePanel.playerVelX;
}
if(GamePanel.playerPositionX < 0)
{
moveLeft = false;
GamePanel.playerPositionX = 0;
}
if(moveRight == true)
{
GamePanel.playerPositionX += GamePanel.playerVelX;
}
if(GamePanel.playerPositionX > 1135)
{
moveRight = false;
GamePanel.playerPositionX = 1135;
}
if(GamePanel.playerVelY <= 10)
{
GamePanel.playerVelY += GamePanel.acceleration;
}
GamePanel.playerPositionY += GamePanel.playerVelY;
//System.out.println(GamePanel.playerVelY);
if(GamePanel.playerPositionY > 811){
GamePanel.playerPositionY = 811;
GamePanel.acceleration = 0;
GamePanel.playerVelY = 0;
}
for(plateform plateform : GamePanel.currentPlateformCourse)
{
if(GamePanel.playerPositionY + GamePanel.playerSizeY >= plateform.blockPositionY && GamePanel.playerPositionY + GamePanel.playerSizeY < plateform.blockPositionY + plateform.blockSizeY/2 && GamePanel.playerPositionX + GamePanel.playerSizeX > plateform.blockPositionX && GamePanel.playerPositionX < plateform.blockPositionX + plateform.blockSizeX)
{
GamePanel.playerPositionY = plateform.blockPositionY - GamePanel.playerSizeY;
GamePanel.acceleration = 0;
GamePanel.playerVelY = 0;
}
else
{
GamePanel.acceleration = 3;
}
if(GamePanel.playerPositionY <= plateform.blockPositionY + plateform.blockSizeY && GamePanel.playerPositionY > plateform.blockPositionY + plateform.blockSizeY/2 && GamePanel.playerPositionX + GamePanel.playerSizeX > plateform.blockPositionX && GamePanel.playerPositionX < plateform.blockPositionX + plateform.blockSizeX)
{
GamePanel.playerPositionY = plateform.blockPositionY + plateform.blockSizeY;
GamePanel.playerVelY = 0;
}
}
if(GamePanel.playerPositionY + GamePanel.playerSizeY >= lavaCollison.lavaPositionY)
{
GamePanel.endScreenFrame = true;
}
}
@Override
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'keyPressed'");
}
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'keyReleased'");
}
@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'keyTyped'");
}
}