-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevel.java
More file actions
104 lines (90 loc) · 2.02 KB
/
Level.java
File metadata and controls
104 lines (90 loc) · 2.02 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
* This class handles everything to do with the level or difficulty of the game
* @author elan
*
*/
public class Level
{
/**
* some Static class variables
*/
private static int level = 1;
private static int enemyRows = 2;
private static int enemyCols = 5;
/**
* adjusts the difficulty of the level
*/
public static void levelUp()
{
PowerUp.clearPowerUps();
level++;
States.enemySpeed *= 1.1;
States.enemyBulletSpeed *= 1.1;
States.enemyDamage *= 1.2;
States.enemyShootDelay *= 0.9;
States.enemyHealth *= 1.1;
GameTimer.updateTimers();
if(level % 3 == 0)
enemyRows++;
if(level % 4 == 0)
enemyCols++;
if(States.debug)
System.out.println("LEVEL UP!");
}
/**
* resets the level back to one
*/
public static void resetLevel()
{
level = 1;
enemyRows = 2;
enemyCols = 5;
}
/**
* @return the amount of rows of enemies
*/
public static int getEnemyRows()
{
return enemyRows;
}
/**
* @return the amount of columns of enemies
*/
public static int getEnemyCols()
{
return enemyCols;
}
/**
* @return integer representing how difficult the level is,
* the higher the more difficult
*/
public static int difficultyIndex()
{
return (int) (level + enemyRows*enemyCols + (States.enemySpeed + States.enemyBulletSpeed)/(double)States.WINDOW_CENTRE + States.enemyDamage + (1500 - States.enemyShootDelay) + States.enemyHealth);
}
/**
* @return level
*/
public static int getLevel()
{
return level;
}
/**
* @return the chance of a power being dropped by an enemy,
* depending on the difficulty of the level
*/
public static boolean powerUpChance()
{
int difficulty = difficultyIndex();
if((int)(Math.random()*(difficulty - (int)(Math.random()*(difficulty)))) > level*70)
return true;
return false;
}
/**
* draws the level variables on the screen
*/
public static void render()
{
StdDraw.text(States.WINDOW_RESOLUTION/(double)8, States.WINDOW_RESOLUTION - States.WINDOW_RESOLUTION/(double)30, "LEVEL: " + level);
}
}