-
Notifications
You must be signed in to change notification settings - Fork 0
/
Battle.java
71 lines (58 loc) · 1.7 KB
/
Battle.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.*;
/**
* Write a description of class Battle here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Battle extends World
{
public boolean first = true;
public int area;
public ActorWorld world;
public Enemy myEnemy;
public Player player;
/**
* Constructor for objects of class Battle.
*
*/
public Battle(int are, ActorWorld worl, Enemy myEnem, Player playe)
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(500, 500, 1, true);
area = are;world=worl;myEnemy=myEnem;player=playe;
area=3;
}
public void act()
{
//Background images
switch(area)
{
case 1:
setBackground("forest.png");
break;
case 2:
setBackground("snow.png");
break;
case 3:
setBackground("Mountain1.png");
break;
default:
setBackground("inside.png");
}
if(first)
{
addObject(new PlayerBattle(), 108, 270);
String s = myEnemy.getClass().toString();
s=s.substring(6);
if(s.equals("Enemy1"))
addObject(new Enemy1Battle(), 410,270);
addObject(new BattleMenu(player,myEnemy),0,0);first=!first;}
removeObjects(getObjects(PlayerHealth.class));
addObject(new PlayerHealth(player), 410,430);
addObject(new PlayerMana(player),410,460);
addObject(new EnemyHealth(myEnemy),435,25);
addObject(new EnemyMana(myEnemy),435,55);
}
}