-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trap.java
executable file
·101 lines (93 loc) · 1.48 KB
/
Trap.java
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import java.awt.*;
import java.awt.Event.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
public class Trap
{
public int type;
public Screen s;
public boolean used;
public Image image;
public Trap(int typeIn, Screen sIn)
{
type = typeIn;
s = sIn;
used = false;
}
public void action(Screen sIn)
{
if(type == 2)
{
//hole
sIn.game.player.lives--;
sIn.game.player.health = 100;
sIn.game.restartLevel();
}
else if(type == 3)
{
//spike
sIn.game.player.health -= 1;
}
else if(type == 4)
{
if(used == false)
{
sIn.game.player.health += 10;
used = true;
s.game.removeTrap();
}
}
//machinegun ammo?
else if(type == 5)
{
if(used == false)
{
sIn.game.player.weapons[1].ammo += 20;
used = true;
s.game.removeTrap();
}
}
//shotgun
else if(type == 6)
{
if(used == false)
{
sIn.game.player.weapons[2].ammo += 10;
used = true;
s.game.removeTrap();
}
}
//rocket
else if(type == 7)
{
if(used == false)
{
sIn.game.player.weapons[3].ammo += 5;
used = true;
s.game.removeTrap();
}
}
//fire
else if(type == 8)
{
if(used == false)
{
sIn.game.player.weapons[4].ammo += 10;
used = true;
s.game.removeTrap();
}
}
//KNIFE GUN!!!!eleven!1
else if(type == 9)
{
if(used == false)
{
sIn.game.player.weapons[5].ammo += 400;
used = true;
s.game.removeTrap();
}
}
}
}