-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRedDarknut.java
More file actions
110 lines (96 loc) · 2.43 KB
/
RedDarknut.java
File metadata and controls
110 lines (96 loc) · 2.43 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
105
106
107
108
109
110
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import java.awt.event.*;
import java.util.*;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.imageio.ImageIO;
//import json.org.*;
public class RedDarknut extends Monster{
// Global Variables
//public JLabel theLabel = new JLabel("SAGFAD");
public RedDarknut(int theX, int theY, /*BufferedImage theScreenShot,*/ ZeldaPlayWindow theWindow, int theNum) {
super(theX, theY, theWindow, theNum);
for (int i = 0; i < 8; i++){
try{
this.monPic[i] = ImageIO.read(new File("Monster Sprites/Darknut/R" + i + ".gif")); //Saves each of Link's pictures for easy access
//this.linkPic[i].setOpaque(false);
}
catch (IOException e){
}
}
this.switchImage = true;
this.image = this.monPic[0];
this.straightWalking = 3;
this.speed = 11;
this.HP = 4;
this.strength = 2;
this.damaging = true;
}
public void run(){
this.appear();
(new Thread(new MonsterChange(this))).start();
while (1>0){
if (!this.hurt || !this.knockBack){
this.move();
this.checkChange();
if (this.defend()){
this.invincible = true;
}
else {
this.invincible = false;
}
this.linkHit();
this.monHit();
try{
Thread.sleep(this.speed); //Delay his next image change
}
catch (InterruptedException e){
}
}
else {
this.monockback();
}
hurtCount++;
if (hurtCount == 69){
if (!this.knockBack){
this.hurt = false;
this.invincible = false;
this.flash = false;
}
else {
hurtCount = 0;
this.knockBack = false;
}
}
if (this.HP == 0){
this.die(); //Homestuck reference FTW!
break;
}
try{
Thread.sleep(1); //Delay his next image change
}
catch (InterruptedException e){
}
}
}
public boolean defend(){
if (this.window.thePlayer.sDirection == "u" && this.direction == "d"){
return true;
}
else if (this.window.thePlayer.sDirection == "d" && this.direction == "u"){
return true;
}
else if (this.window.thePlayer.sDirection == "r" && this.direction == "l"){
return true;
}
else if (this.window.thePlayer.sDirection == "l" && this.direction == "r"){
return true;
}
return false;
}
}