“This is the 12th day of my participation in the First Challenge 2022. For details: First Challenge 2022”
❤️ Author’s home page: Xiao Xu Zhu
❤️ About the author: Hello everyone, I am Xiao Xu Zhu. Java field quality creator 🏆, CSDN blog expert 🏆, Huawei cloud enjoy expert 🏆, Nuggets of the year popular author 🏆, Ali Cloud expert blogger 🏆
❤️ technology live, the appreciation
❤️ like 👍 collect ⭐ look again, form a habit
preface
“Turnip Brave” is an independent game made by domestic players, players play turnip warriors through the pass, defeat all kinds of evil enemies, to obtain the final victory.
“Turnip Brave” game is implemented in Java language, using swing technology for interface processing, design ideas with object-oriented thought.
The main requirements
Reference “turnip brave” story, JAVA version of the standalone game.
The main design
1, use Swing library to do visual interface
2, keyboard monitor, WSAD can control cursor movement, J is to confirm, K is to cancel, the game, WSAD movement, J attack, K block.
3, with thread to achieve picture refresh.
4. Use stream to play music.
5, support multiple languages, support users to translate language files.
6, in the help interface, press the keyboard 1234567890 can enable the secret (legend mode: one knife 999 blood)
7. Use JDK8
8. File code GBK
Screenshot function
The game start
Games help
The game is set
Choose different levels
The game effect
Monster attack effect
Code implementation
Start the class
@SuppressWarnings("serial")
public class TestWindowBuilder extends JFrame {
TextLibrary textLib;
settingLoader settingLib;
private JPanel contentPane;
boolean isCheating;
saveSelect saveSelectMenu;
int[] startMenuPointer=new int[1];
JLabel lblNewLabel1;
JLabel lblNewLabel2;
JLabel lblNewLabel3;
JLabel lblNewLabel3_2;
JLabel lblNewLabel3_1;
JLabel lblNewLabel4;
JLabel lblNewLabel5;
JLabel lblNewLabel6;
CMusicLink CMLHead=new CMusicLink(1);
CMusicLink CMLLast=new CMusicLink(2);
boolean sawExplain=true;
CMusic menuBGMusic;
/** * Launch the application. */
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run(a) {
try {
TestWindowBuilder frame = new TestWindowBuilder();
frame.setVisible(true);
} catch(Exception e) { e.printStackTrace(); }}}); }/** * Create the frame. */
public TestWindowBuilder(a) {
this.setTitle("CARROT MAN II");
this.setIconImage(new ImageIcon("resource/down4.png").getImage());
int screenWidth=Calculator.setInside(ScreenSize.getWidth(), 800.99999);
int screenHeight=Calculator.setInside(ScreenSize.getHeight(), 450.99999);
System.out.println("Start console 222...");
CMLHead.next=CMLLast;
CMLLast.prev=CMLHead;
settingLib=new settingLoader();
settingLib.loadSetting();// Load the Settings
settingLib.saveSetting();
textLib=new TextLibrary();
textLib.saveText();// Create a default language file
textLib.loadText(settingLib.settings[0]);
startNewMenuBGMusic(1);
/* Game stage: * 0 start menu * */
int gamePhase=0;
isCheating=false;
/* Start menu pointer * 0 start * 1 help * 2 exit * */
startMenuPointer[0] =0;
int allSMPCount=5;// Total number of Pointers
TestWindowBuilder testMenu=this;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds((screenWidth-800) /2, (screenHeight-450) /2.800.450);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5.5.5.5));
setContentPane(contentPane);
contentPane.setLayout(null);
JPanel mainMenu = new JPanel();
mainMenu.setBounds(0.0.784.412);
contentPane.add(mainMenu);
mainMenu.setLayout(null);
lblNewLabel1 = new JLabel();// Menu title
lblNewLabel1.setBounds(192.10.400.150);
lblNewLabel1.setIcon(new ImageIcon("resource/MenuTitle.png"));
mainMenu.add(lblNewLabel1);
lblNewLabel2 = new JLabel();/ /
lblNewLabel2.setBounds(10.193.764.43);
lblNewLabel2.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel2.setFont(new Font(Adobe Boldface Std R, Font.PLAIN, 21));
lblNewLabel2.setForeground(new Color(200.200.200));
mainMenu.add(lblNewLabel2);
lblNewLabel3 = new JLabel();/ / help
lblNewLabel3.setBounds(10.223.764.43);
lblNewLabel3.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel3.setFont(new Font(Adobe Boldface Std R, Font.PLAIN, 21));
lblNewLabel3.setForeground(new Color(200.200.200));
mainMenu.add(lblNewLabel3);
lblNewLabel3_2 = new JLabel();/ / set
lblNewLabel3_2.setBounds(10.253.764.43);
lblNewLabel3_2.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel3_2.setFont(new Font(Adobe Boldface Std R, Font.PLAIN, 21));
lblNewLabel3_2.setForeground(new Color(200.200.200));
mainMenu.add(lblNewLabel3_2);
lblNewLabel3_1 = new JLabel();/ / language
lblNewLabel3_1.setBounds(10.283.764.43);
lblNewLabel3_1.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel3_1.setFont(new Font(Adobe Boldface Std R, Font.PLAIN, 21));
lblNewLabel3_1.setForeground(new Color(200.200.200));
mainMenu.add(lblNewLabel3_1);
lblNewLabel4 = new JLabel();/ / exit
lblNewLabel4.setBounds(10.313.764.43);
lblNewLabel4.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel4.setFont(new Font(Adobe Boldface Std R, Font.PLAIN, 21));
lblNewLabel4.setForeground(new Color(200.200.200));
mainMenu.add(lblNewLabel4);
lblNewLabel5 = new JLabel(textLib.textData[5]);// Bottom prompt
lblNewLabel5.setBounds(10.371.764.31);
lblNewLabel5.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel5.setFont(new Font(Adobe Boldface Std R, Font.PLAIN, 15));
lblNewLabel5.setForeground(new Color(200.200.200));
mainMenu.add(lblNewLabel5);
lblNewLabel6 = new JLabel();// Semi-transparent black background
lblNewLabel6.setBounds(267.193.250.209);
lblNewLabel6.setIcon(new ImageIcon("resource/mainMenuButtonBackGround.png"));
mainMenu.add(lblNewLabel6);
JLabel MenuBackGroundLabel = new JLabel();// White background
MenuBackGroundLabel.setBounds(0.0.800.450);
MenuBackGroundLabel.setIcon(new ImageIcon("resource/mainMenuBackGround.png"));
mainMenu.add(MenuBackGroundLabel);
reflash();
// Keyboard listener
this.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
char cmd=e.getKeyChar();
if(gamePhase==0)// Start menu
{
if(sawExplain==false)
{
sawExplain=true;
StartView sv=new StartView(testMenu);
sv.setVisible(true);
testMenu.setVisible(false);
}
else
{
if(TestWindowBuilder.charEqualsIgnoreCase(cmd, 'w'))
{
startMenuPointer[0]=(startMenuPointer[0] -1+allSMPCount)%allSMPCount;
startNewSound("pointerMove.wav".false.1);
}
if(TestWindowBuilder.charEqualsIgnoreCase(cmd, 's'))
{
startMenuPointer[0]=(startMenuPointer[0] +1)%allSMPCount;
startNewSound("pointerMove.wav".false.1);
}
reflash();
if(TestWindowBuilder.charEqualsIgnoreCase(cmd, 'j'))
{
if(startMenuPointer[0] = =0)
{
saveSelectMenu=new saveSelect(testMenu);
saveSelectMenu.setVisible(true);
testMenu.setVisible(false);
startNewSound("menuChange.wav".false.1);
}
if(startMenuPointer[0] = =1)
{
HelpMenu helpMenu=new HelpMenu(testMenu);
helpMenu.setVisible(true);
testMenu.setVisible(false);
startNewSound("menuChange.wav".false.1);
}
if(startMenuPointer[0] = =2)
{
settingMenu sMenu=new settingMenu(testMenu);
sMenu.setVisible(true);
testMenu.setVisible(false);
startNewSound("menuChange.wav".false.1);
}
if(startMenuPointer[0] = =3)
{
settingLanguage settingMenu=new settingLanguage(testMenu);
settingMenu.setVisible(true);
testMenu.setVisible(false);
startNewSound("menuChange.wav".false.1);
}
if(startMenuPointer[0] = =4)
{
startNewSound("menuChange.wav".false.1);
System.exit(0); }}}}}}); }public void reflash(a)
{
lblNewLabel1.setText(textLib.textData[1]);
lblNewLabel2.setText(textLib.textData[6]);
lblNewLabel3.setText(textLib.textData[3]);
lblNewLabel3_2.setText(textLib.textData[60]);
lblNewLabel3_1.setText(textLib.textData[49]);
lblNewLabel4.setText(textLib.textData[4]);
lblNewLabel5.setText(textLib.textData[5]);
if(startMenuPointer[0] = =0)
{
lblNewLabel2.setText(textLib.textData[6] +"< -");
}
if(startMenuPointer[0] = =1)
{
lblNewLabel3.setText(textLib.textData[3] +"< -");
}
if(startMenuPointer[0] = =2)
{
lblNewLabel3_2.setText(textLib.textData[60] +"< -");
}
if(startMenuPointer[0] = =3)
{
lblNewLabel3_1.setText(textLib.textData[49] +"< -");
}
if(startMenuPointer[0] = =4)
{
lblNewLabel4.setText(textLib.textData[4] +"< -"); }}public void startNewMenuBGMusic(int prepare)
{
if(settingLib.settings[1].equals("1"))
{
if(menuBGMusic! =null)
menuBGMusic.endMusic();
menuBGMusic=new CMusic("menuMusic.wav".true.30000);
menuBGMusic.start();
}
else if(prepare==1)
{
if(menuBGMusic! =null)
menuBGMusic.endMusic();
menuBGMusic=new CMusic("menuMusic.wav".true.30000); menuBGMusic.start(); menuBGMusic.pauseMusic(); }}public void startNewSound(String soundName,boolean isReplay,int replayDelay)// Start a new sound
{
if(settingLib.settings[2].equals("1"))
new CMusicLink(CMLLast,soundName,isReplay,replayDelay);
}
/** * Determine whether the letters A and B are the same (case insensitive) *@paramA the letter A *@paramB The letter b star@returnTrue: the letters a and b | false: same letters a and b, or ab * / in the letters
public static boolean charEqualsIgnoreCase(char a,char b)
{
if(((int)a)>=65&& ((int)a)<=90)/ / the capital
{
if(a==b)
return true;
if(a+32==b)
return true;
}
if(((int)a)>=97&& ((int)a)<=122)/ / lowercase
{
if(a==b)
return true;
if(a-32==b)
return true;
}
return false; }}Copy the code
Keyboard monitor
public class KeyLininter extends KeyAdapter
{
GameMenu gameMenu;
public KeyLininter(GameMenu gameMenu)
{
this.gameMenu=gameMenu;
}
public void keyPressed(KeyEvent e) {
char cmd = e.getKeyChar();
if(cmd=='w'||cmd=='W')
{
gameMenu.pressingW=1;
}
if(cmd=='s'||cmd=='S')
{
gameMenu.pressingS=1;
}
if(cmd=='a'||cmd=='A')
{
gameMenu.pressingA=1;
}
if(cmd=='d'||cmd=='D')
{
gameMenu.pressingD=1;
}
if(cmd=='j'||cmd=='J')
{
gameMenu.pressingJ=1;
}
if(cmd=='k'||cmd=='K')
{
gameMenu.pressingK=1; }}public void keyReleased(KeyEvent e)
{
char cmd = e.getKeyChar();
if(cmd=='w'||cmd=='W')
{
gameMenu.pressingW=0;
}
if(cmd=='s'||cmd=='S')
{
gameMenu.pressingS=0;
}
if(cmd=='a'||cmd=='A')
{
gameMenu.pressingA=0;
}
if(cmd=='d'||cmd=='D')
{
gameMenu.pressingD=0;
}
if(cmd=='j'||cmd=='J')
{
gameMenu.pressingJ=0;
}
if(cmd=='k'||cmd=='K')
{
gameMenu.pressingK=0; }}}Copy the code
The core algorithm
@SuppressWarnings("serial")
public class GameMenu extends JFrame {
GameMenu thisMenu;
private JPanel contentPane;
TestWindowBuilder fatherMenu;
boolean isCheating;
CMusic battleBGM,questCompleteBGM;
int pressingW;
int pressingS;
int pressingA;
int pressingD;
int pressingJ;
int pressingK;
int playingSave;
int playingProfessionID;
int g_int1;
Role playingRole;
double playerX;/ / 0-734
double playerY;/ / 0-312
int rotationSpeed=15;// Rotation speed
int movementSpeed=3;// Move speed
int NormalSpeed=3;
int attackSpeed=3;// Attack speed
int activeCounter;
int attackCounter;
int defenceCounter=0;
int perfectDefenceTime=0;// The remaining time to complete a block (starting the block 0.1 seconds before the enemy attacks reduces the energy cost of the block by 1/10)
int defenceCooldown=0;// Block cooldown this prevents the player from frantically starting/stopping blocks
int playerWidth=50;
int playerHeight=50;
int gamePhaseTimeCounter=0;
int gamePhaseTimeCounter2=0;
int endPhase=6*4;// The stage in which the game is completed
/* Level 1 0 * Level 2 6 * */
int gamePhase=0;// Stage at the beginning of the game (normal players should start from level 1, stage should start from 0)
String humanIconContorler;
JPanel viewMap;
// Players have two labels, one above and one below the boss
int usingPlayerLabel=0;
JLabel[] playerLabel=new JLabel[2];
JLabel lblNewLabel_6;
JLabel lblNewLabel_7;
JLabel[] GiantBackGround=new JLabel[400];
JLabel bossLabel;
JLabel lblNewLabel_2;
JLabel lblNewLabel_3;
JLabel lblNewLabel_2B;
JLabel lblNewLabel_3B;
JLabel MobHead;
JLabel MobName;
JLabel MobHPBar;
JLabel MobHPText;
JLabel TitleLabelT;
JLabel SubTitleLabelT;
JLabel TitleLabel;
JLabel SubTitleLabel;
JPanel Titles;
JLabel placeNameLabel;
JLabel groundArrayLabel;
JLabel placeChangeBlack;// The dark scene at the venue change
JLabel placeChangeBlack_1;// Black screen when changing venue (used for property bar)
int maxProCount=5000;
JLabel[] proLabel=new JLabel[maxProCount];
boolean[] proIsUsed=new boolean[maxProCount];
proLink proHead=new proLink();
int existProCount;
int maxParCount=5000;
JLabel[] parLabel=new JLabel[maxParCount];
boolean[] parIsUsed=new boolean[maxParCount];
parLink parHead=new parLink();
int existParCount;
int existPro=0;
int proTeamPointer=0;// Queue Pointers 0-499
int existPar=0;
int parTeamPointer=0;
JPanel panel;
Mob boss;
int allPhaseCount=1;
int gameTime=0;
Map map;
/** * Create the frame. */
public GameMenu(TestWindowBuilder fatherMenu,boolean isCheating,int professionID,int partID,int playingSave)
{
this.setTitle("CARROT MAN II");
this.setIconImage(new ImageIcon("resource/down4.png").getImage());
for(int i=0; i<proIsUsed.length; ++i) proIsUsed[i]=false;
for(int i=0; i<parIsUsed.length; ++i) parIsUsed[i]=false;
playingProfessionID=professionID;
this.playingSave=playingSave;
gamePhase=(partID-1) *6;
this.fatherMenu=fatherMenu;
this.isCheating=isCheating;
//this.isCheating=true; / / test
g_int1=0;
playerX=50;
playerY=200;
thisMenu=this;
activeCounter=0;
attackCounter=0;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(fatherMenu.getBounds());
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5.5.5.5));
setContentPane(contentPane);
contentPane.setLayout(null);
// It's on the 100th floor
placeChangeBlack=new JLabel("");
placeChangeBlack.setIcon(new ImageIcon("resource/black.png"));
placeChangeBlack.setVisible(true);
placeChangeBlack_1=new JLabel("");
placeChangeBlack_1.setIcon(new ImageIcon("resource/black.png"));
placeChangeBlack_1.setVisible(true);
placeChangeBlack.setBounds(0.0.784.362);
placeChangeBlack_1.setBounds(0.0.784.362);
//contentPane.add(placeChangeBlack);
JPanel panel_1 = new JPanel();
panel_1.setBounds(0.0.784.50);
contentPane.add(panel_1);
panel_1.setLayout(null);
panel_1.add(placeChangeBlack_1);
JLabel lblNewLabel = new JLabel("");/ / avatar
lblNewLabel.setBounds(0.0.50.50);
lblNewLabel.setIcon(new ImageIcon("resource/HPBarHead.png"));
panel_1.add(lblNewLabel);
lblNewLabel_2B = new JLabel("");/ / HP
lblNewLabel_2B.setForeground(Color.WHITE);
lblNewLabel_2B.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_2B.setBounds(50.0.200.25);
panel_1.add(lblNewLabel_2B);
lblNewLabel_3B = new JLabel("");/ / physical characters
lblNewLabel_3B.setForeground(Color.WHITE);
lblNewLabel_3B.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_3B.setBounds(50.25.200.25);
panel_1.add(lblNewLabel_3B);
lblNewLabel_2 = new JLabel("");/ / the blood
lblNewLabel_2.setBounds(50.0.200.25);
lblNewLabel_2.setIcon(new ImageIcon("resource/RedBar.png"));
panel_1.add(lblNewLabel_2);
lblNewLabel_3 = new JLabel("");/ / manual
lblNewLabel_3.setBounds(50.25.200.25);
lblNewLabel_3.setIcon(new ImageIcon("resource/GreenBar.png"));
panel_1.add(lblNewLabel_3);
JLabel lblNewLabel_1 = new JLabel("");// Health bar physical bar background
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_1.setBounds(50.0.200.50);
lblNewLabel_1.setIcon(new ImageIcon("resource/HPBarBG.png"));
panel_1.add(lblNewLabel_1);
JLabel lblNewLabel_4 = new JLabel("J");
lblNewLabel_4.setForeground(Color.GRAY);
lblNewLabel_4.setFont(new Font("Black", Font.BOLD, 30));
lblNewLabel_4.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_4.setBounds(250.0.50.50);
panel_1.add(lblNewLabel_4);
JLabel lblNewLabel_5 = new JLabel("");
lblNewLabel_5.setFont(new Font("宋体", Font.PLAIN, 20));
lblNewLabel_5.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_5.setBounds(250.0.50.50);
lblNewLabel_5.setIcon(new ImageIcon("resource/skillJ.png"));
panel_1.add(lblNewLabel_5);
JLabel skillKLabel = new JLabel("K");
skillKLabel.setForeground(Color.GRAY);
skillKLabel.setFont(new Font("Black", Font.BOLD, 30));
skillKLabel.setHorizontalAlignment(SwingConstants.CENTER);
skillKLabel.setBounds(300.0.50.50);
panel_1.add(skillKLabel);
JLabel skillKLabel2 = new JLabel("");
skillKLabel2.setFont(new Font("宋体", Font.PLAIN, 20));
skillKLabel2.setHorizontalAlignment(SwingConstants.CENTER);
skillKLabel2.setBounds(300.0.50.50);
skillKLabel2.setIcon(new ImageIcon("resource/skillK.png"));
panel_1.add(skillKLabel2);
placeNameLabel = new JLabel("");
placeNameLabel.setFont(new Font("宋体", Font.PLAIN, 30));
placeNameLabel.setHorizontalAlignment(SwingConstants.CENTER);
placeNameLabel.setBounds(350.0.200.50);
panel_1.add(placeNameLabel);
JLabel placeNameLabel2 = new JLabel("");
placeNameLabel2.setHorizontalAlignment(SwingConstants.CENTER);
placeNameLabel2.setBounds(350.0.200.50);
placeNameLabel2.setIcon(new ImageIcon("resource/placeNameBackGround.png"));
panel_1.add(placeNameLabel2);
MobHead = new JLabel("");
MobHead.setHorizontalAlignment(SwingConstants.CENTER);
MobHead.setBounds(550.0.50.50);
MobHead.setIcon(new ImageIcon("resource/MobHead_0.png"));
panel_1.add(MobHead);
MobName = new JLabel("");
MobName.setHorizontalAlignment(SwingConstants.CENTER);
MobName.setBounds(600.0.184.25);
panel_1.add(MobName);
MobHPText = new JLabel("");
MobHPText.setForeground(Color.WHITE);
MobHPText.setHorizontalAlignment(SwingConstants.CENTER);
MobHPText.setBounds(600.25.184.25);
panel_1.add(MobHPText);
MobHPBar = new JLabel("");
MobHPBar.setHorizontalAlignment(SwingConstants.CENTER);
MobHPBar.setBounds(600.25.184.25);
MobHPBar.setIcon(new ImageIcon("resource/RedBar.png"));
panel_1.add(MobHPBar);
JLabel MobNameBG = new JLabel("");
MobNameBG.setHorizontalAlignment(SwingConstants.CENTER);
MobNameBG.setBounds(600.0.184.50);
MobNameBG.setIcon(new ImageIcon("resource/MobNameBG.png"));
panel_1.add(MobNameBG);
panel = new JPanel();
panel.setBounds(0.50.784.362);
contentPane.add(panel);
viewMap=panel;
panel.setLayout(null);
panel.add(placeChangeBlack);
lblNewLabel_7 = new JLabel("");// Player tryingFace indicator (temporarily disabled)
lblNewLabel_7.setBounds((int)playerX, (int)playerY, 5.5);
lblNewLabel_7.setIcon(new ImageIcon("resource/moveDeraction2.png"));
lblNewLabel_7.setVisible(false);
panel.add(lblNewLabel_7);
/ / the 99th floor
/ / title
TitleLabelT = new JLabel("");
TitleLabelT.setFont(new Font("Black", Font.PLAIN, 45));
TitleLabelT.setHorizontalAlignment(SwingConstants.CENTER);
TitleLabelT.setBounds(100.50.584.50);
TitleLabelT.setVisible(true);
panel.add(TitleLabelT);
/ / subtitle
SubTitleLabelT = new JLabel("");
SubTitleLabelT.setFont(new Font("Black", Font.PLAIN, 25));
SubTitleLabelT.setHorizontalAlignment(SwingConstants.CENTER);
SubTitleLabelT.setBounds(100.100.584.50);
SubTitleLabelT.setVisible(true);
panel.add(SubTitleLabelT);
// Pre-created particle effect Label, layer 6
for(int i=0; i<maxParCount; ++i) { parLabel[i]=new JLabel("");
panel.add(parLabel[i]);
}
// The player above the boss, tier 5
playerLabel[1] =new JLabel("");
playerLabel[1].setHorizontalAlignment(SwingConstants.CENTER);
playerLabel[1].setBounds((int)playerX-playerWidth/2, (int)playerY-playerHeight/2, playerHeight, playerWidth);
playerLabel[1].setIcon(new ImageIcon("resource/HumanRight_0.png"));
playerLabel[1].setVisible(false);
panel.add(playerLabel[1]);
//bossLabel, level 4.5
bossLabel = new JLabel("");
panel.add(bossLabel);
// The player below the boss, tier 4
playerLabel[0] =new JLabel("");
playerLabel[0].setHorizontalAlignment(SwingConstants.CENTER);
playerLabel[0].setBounds((int)playerX-playerWidth/2, (int)playerY-playerHeight/2, playerHeight, playerWidth);
playerLabel[0].setIcon(new ImageIcon("resource/HumanRight_0.png"));
playerLabel[0].setVisible(true);
panel.add(playerLabel[0]);
// Player oriented indicator, level 3
lblNewLabel_6 = new JLabel("");
lblNewLabel_6.setBounds((int)playerX, (int)playerY, 5.5);
lblNewLabel_6.setIcon(new ImageIcon("resource/moveDeraction.png"));
panel.add(lblNewLabel_6);
// Pre-create emitter Label, layer 2
for(int i=0; i<maxProCount; ++i) { proLabel[i]=new JLabel("");
panel.add(proLabel[i]);
}
// Create ground arrow, layer 1.5
groundArrayLabel=new JLabel("");
groundArrayLabel.setBounds(709.156.50.50);
groundArrayLabel.setIcon(new ImageIcon("resource/groundArray.png"));
groundArrayLabel.setVisible(false);
panel.add(groundArrayLabel);
// Create ground Label, layer 1
for(int i=0; i<400; ++i) { GiantBackGround[i]=new JLabel("");
GiantBackGround[i].setVisible(true);
panel.add(GiantBackGround[i]);
}
playingRole=new Role(professionID,thisMenu);
KeyLininter kl=new KeyLininter(thisMenu);
this.addKeyListener(kl);
map=new Map(thisMenu);
map.start();
}
// Emission correlation
public int addProjectile(Projectile pro)
{
existProCount=proHead.getLength();
if(existProCount<maxProCount)
{
proHead.insert(new proLink(pro));
int tempFinder=0;
for(int i=0; i<maxProCount; ++i) {if(proIsUsed[i]==false)
{
proIsUsed[i]=true;
tempFinder=i;
break; }}return tempFinder;
}
return -1;
}
public void removeProjectile(int id)
{
proLabel[id].setVisible(false);
proIsUsed[id]=false;
}
public void allProjectilesFly(a)
{
proLink tempNode=proHead;
while(tempNode.next! =null) { tempNode=tempNode.next; tempNode.data.doFly(); }}// End of emitter correlation
// Particle effects are related
public int addParticle(particle par)
{
existParCount=parHead.getLength();
if(existParCount<maxParCount)
{
parHead.insert(new parLink(par));
int tempFinder=0;
for(int i=0; i<maxParCount; ++i) {if(parIsUsed[i]==false)
{
parIsUsed[i]=true;
tempFinder=i;
break; }}return tempFinder;
}
return -1;
}
public void removeParticle(int id)
{
parLabel[id].setVisible(false);
parIsUsed[id]=false;
}
public void allParticlesFly(a)
{
parLink tempNode=parHead;
while(tempNode.next! =null) { tempNode=tempNode.next; tempNode.data.doFly(); }}public void checkPlayerLocation(a)// Check the player's position and pull back to the map if it is off the map
{
if(playerX<playerWidth/2)
playerX=playerWidth/2;
if(playerX>784-playerWidth/2)
playerX=784-playerWidth/2;
if(playerY<playerHeight/2)
playerY=playerHeight/2;
if(playerY>362-playerHeight/2)
playerY=362-playerHeight/2;
}
@SuppressWarnings("unused")
public void saveData(int part)
{
if(Integer.parseInt(fatherMenu.saveSelectMenu.savedData[playingSave].split("") [1])<part)
{
String[] temp= {
fatherMenu.saveSelectMenu.savedData[playingSave].split("") [0],
fatherMenu.saveSelectMenu.savedData[playingSave].split("") [1]}; fatherMenu.saveSelectMenu.savedData[playingSave]=""+playingProfessionID+""+part; fatherMenu.saveSelectMenu.saveSaves(); }}@SuppressWarnings({ "deprecation" })
public void modTick(a)// Execute 50 times per second
{
if(attackCounter==0&&defenceCounter==0)
playingRole.regenerate();
if(playingRole.HP>0)
{
// Refresh the health bar
lblNewLabel_3.setBounds(50.25, (int) (200*playingRole.energy/playingRole.MaxEnergy), 25);
lblNewLabel_3B.setText(""+ (int)playingRole.energy+"/"+ (int)playingRole.MaxEnergy);
// Refresh health bar
lblNewLabel_2.setBounds(50.0, (int) (200*playingRole.HP/playingRole.MaxHP), 25);
lblNewLabel_2B.setText(""+ (int)playingRole.HP+"/"+ (int)playingRole.MaxHP);
}
else if(gamePhase! = -1)
{
boss.target=null;
gamePhaseTimeCounter=0;
gamePhase=-1;
movementSpeed=0;
TitleLabelT.setText("YOU DIED");
TitleLabelT.setVisible(true);
playerLabel[usingPlayerLabel].setVisible(false);
lblNewLabel_6.setVisible(false);
lblNewLabel_3.setBounds(50.25, (int) (200*playingRole.energy/playingRole.MaxEnergy), 25);
lblNewLabel_3B.setText(""+ (int)playingRole.energy+"/"+ (int)playingRole.MaxEnergy);
lblNewLabel_2.setBounds(50.0, (int) (200*playingRole.HP/playingRole.MaxHP), 25);
lblNewLabel_2B.setText(""+ (int)playingRole.HP+"/"+ (int)playingRole.MaxHP);
}
++gameTime;
allProjectilesFly();
allParticlesFly();
if(gamePhase==0)
{
if(gamePhaseTimeCounter<50)
gamePhaseTimeCounter=50;
++gamePhaseTimeCounter;
if(gamePhaseTimeCounter==51)
{
System.out.println("Start the console...");
movementSpeed=0;
placeChangeBlack.setBounds(0.0.784.362);
placeChangeBlack_1.setBounds(0.0.784.362);
placeChangeBlack.setVisible(true);
placeChangeBlack_1.setVisible(true);
TitleLabelT.setVisible(false);
SubTitleLabelT.setVisible(false);
groundArrayLabel.setVisible(false);
for(int i=0; i<128; ++i)// Initialize the first level
{
String backGroundContorler="resource/ground";
GiantBackGround[i].setBounds(50*(i%16),50* (int)(i/16), 50.50);
if(Math.random()<0.9)
backGroundContorler=backGroundContorler+"1.png";
else
backGroundContorler=backGroundContorler+"2.png";
GiantBackGround[i].setIcon(new ImageIcon(backGroundContorler));
}
playerX=50;
playerY=200;
placeNameLabel.setText(fatherMenu.textLib.textData[13]);
TitleLabelT.setText(fatherMenu.textLib.textData[13]);
TitleLabelT.setVisible(true);
SubTitleLabelT.setText(fatherMenu.textLib.textData[37]);
SubTitleLabelT.setVisible(true);
}
if(gamePhaseTimeCounter>=100&&gamePhaseTimeCounter<=150)
{
placeChangeBlack.setBounds((int)((gamePhaseTimeCounter-100) *0.02*784), 0.784.362);
placeChangeBlack_1.setBounds((int)((gamePhaseTimeCounter-100) *0.02*784), 0.784.362);
}
if(gamePhaseTimeCounter==151)
{
startNewBattleBGM(1);
placeChangeBlack.setVisible(false);
placeChangeBlack_1.setVisible(false);
gamePhaseTimeCounter=0; ++gamePhase; }}if(gamePhase%6= =1)
{
++gamePhaseTimeCounter;
if(gamePhaseTimeCounter>=200)
{
++gamePhase;
TitleLabelT.setVisible(false);
SubTitleLabelT.setVisible(false); movementSpeed=NormalSpeed; }}if(gamePhase==2)
{
gamePhaseTimeCounter=0;
boss=new Mob(1,bossLabel,thisMenu);
boss.reflash();
bossLabel.setVisible(true);
++gamePhase;
}
if(gamePhase==3)
{
if(boss.HP>0)
boss.reflash();
else
{
bossLabel.setVisible(false);
MobHPBar.setBounds(600.25.184*boss.HP/boss.MaxHP, 25);
MobHPText.setText(""+boss.HP+"/"+boss.MaxHP);
++gamePhase;
gamePhaseTimeCounter=0;
TitleLabelT.setText(fatherMenu.textLib.textData[38]);
TitleLabelT.setVisible(true);
SubTitleLabelT.setText(fatherMenu.textLib.textData[39]);
SubTitleLabelT.setVisible(true);
saveData(2); startQuestCompleteBGM(); endBattleBGM(); }}if(gamePhase%6= =4)
{
playingRole.percentReHP(0.005);
++gamePhaseTimeCounter;
if(gamePhaseTimeCounter>200)
{
gamePhaseTimeCounter=0;
++gamePhase;
TitleLabelT.setText(fatherMenu.textLib.textData[40]);
TitleLabelT.setVisible(true);
SubTitleLabelT.setText(fatherMenu.textLib.textData[41]);
SubTitleLabelT.setVisible(true);
gamePhaseTimeCounter2=0; }}if(gamePhase%6= =5)
{
++gamePhaseTimeCounter;
if(gamePhaseTimeCounter2==0)
{
if(gamePhaseTimeCounter>50)
{
groundArrayLabel.setVisible(true);
if(playerX>709&&playerX<759&&playerY>156&&playerY<206)// Enter the arrow
{
gamePhaseTimeCounter=0;
gamePhaseTimeCounter2=1;
movementSpeed=0;
placeChangeBlack.setBounds(-784.0.784.362);
placeChangeBlack.setVisible(true);
placeChangeBlack_1.setBounds(-784.0.784.362);
placeChangeBlack_1.setVisible(true); }}}if(gamePhaseTimeCounter2==1)
{
if(gamePhaseTimeCounter>=0&&gamePhaseTimeCounter<=50)
{
placeChangeBlack.setBounds((int)(gamePhaseTimeCounter*0.02*784-784), 0.784.362);
placeChangeBlack_1.setBounds((int)(gamePhaseTimeCounter*0.02*784-784), 0.784.362);
}
if(gamePhaseTimeCounter==51)
{
++gamePhase;
gamePhaseTimeCounter=0; }}}if(gamePhase==6)
{
movementSpeed=0;
if(gamePhaseTimeCounter<50)
gamePhaseTimeCounter=50;
++gamePhaseTimeCounter;
if(gamePhaseTimeCounter==51)
{
placeChangeBlack.setBounds(0.0.784.362);
placeChangeBlack.setVisible(true);
placeChangeBlack_1.setBounds(0.0.784.362);
placeChangeBlack_1.setVisible(true);
TitleLabelT.setVisible(false);
SubTitleLabelT.setVisible(false);
groundArrayLabel.setVisible(false);
for(int i=0; i<325; ++i) { GiantBackGround[i].setBounds(32*(i%25),32* (int)(i/25), 32.32);
GiantBackGround[i].setIcon(new ImageIcon("resource/ground6.png"));
}
playerX=50;
playerY=200;
placeNameLabel.setText(fatherMenu.textLib.textData[14]);
TitleLabelT.setText(fatherMenu.textLib.textData[14]);
TitleLabelT.setVisible(true);
SubTitleLabelT.setText(fatherMenu.textLib.textData[42]);
SubTitleLabelT.setVisible(true);
}
if(gamePhaseTimeCounter>=100&&gamePhaseTimeCounter<=150)
{
placeChangeBlack.setBounds((int)((gamePhaseTimeCounter-100) *0.02*784), 0.784.362);
placeChangeBlack_1.setBounds((int)((gamePhaseTimeCounter-100) *0.02*784), 0.784.362);
}
if(gamePhaseTimeCounter==151)
{
startNewBattleBGM(2);
placeChangeBlack.setVisible(false);
placeChangeBlack_1.setVisible(false);
gamePhaseTimeCounter=0; ++gamePhase; }}if(gamePhase==8)
{
gamePhaseTimeCounter=0;
boss=new Mob(2,bossLabel,thisMenu);
bossLabel.setBounds(375.175.100.100);
boss.reflash();
bossLabel.setVisible(true);
++gamePhase;
}
if(gamePhase==9)
{
if(boss.HP>0)
boss.reflash();
else
{
bossLabel.setVisible(false);
MobHPBar.setBounds(600.25.184*boss.HP/boss.MaxHP, 25);
MobHPText.setText(""+boss.HP+"/"+boss.MaxHP);
++gamePhase;
gamePhaseTimeCounter=0;
TitleLabelT.setText(fatherMenu.textLib.textData[43]);
TitleLabelT.setVisible(true);
SubTitleLabelT.setText(fatherMenu.textLib.textData[39]);
SubTitleLabelT.setVisible(true);
saveData(3); startQuestCompleteBGM(); endBattleBGM(); }}if(gamePhase==12)
{
movementSpeed=0;
if(gamePhaseTimeCounter<50)
gamePhaseTimeCounter=50;
++gamePhaseTimeCounter;
if(gamePhaseTimeCounter==51)
{
placeChangeBlack.setBounds(0.0.784.362);
placeChangeBlack.setVisible(true);
placeChangeBlack_1.setBounds(0.0.784.362);
placeChangeBlack_1.setVisible(true);
TitleLabelT.setVisible(false);
SubTitleLabelT.setVisible(false);
groundArrayLabel.setVisible(false);
for(int i=0; i<325; ++i) { GiantBackGround[i].setBounds(32*(i%25),32* (int)(i/25), 32.32);
GiantBackGround[i].setIcon(new ImageIcon("resource/ground7.png"));
}
playerX=50;
playerY=200;
placeNameLabel.setText(fatherMenu.textLib.textData[15]);
TitleLabelT.setText(fatherMenu.textLib.textData[15]);
TitleLabelT.setVisible(true);
SubTitleLabelT.setText(fatherMenu.textLib.textData[44]);
SubTitleLabelT.setVisible(true);
}
if(gamePhaseTimeCounter>=100&&gamePhaseTimeCounter<=150)
{
placeChangeBlack.setBounds((int)((gamePhaseTimeCounter-100) *0.02*784), 0.784.362);
placeChangeBlack_1.setBounds((int)((gamePhaseTimeCounter-100) *0.02*784), 0.784.362);
}
if(gamePhaseTimeCounter==151)
{
startNewBattleBGM(3);
placeChangeBlack.setVisible(false);
placeChangeBlack_1.setVisible(false);
gamePhaseTimeCounter=0; ++gamePhase; }}if(gamePhase==14)
{
gamePhaseTimeCounter=0;
boss=new Mob(3,bossLabel,thisMenu);
bossLabel.setBounds(375.175.100.100);
boss.reflash();
bossLabel.setVisible(true);
++gamePhase;
}
if(gamePhase==15)
{
if(boss.HP>0)
boss.reflash();
else
{
bossLabel.setVisible(false);
MobHPBar.setBounds(600.25.184*boss.HP/boss.MaxHP, 25);
MobHPText.setText(""+boss.HP+"/"+boss.MaxHP);
++gamePhase;
gamePhaseTimeCounter=0;
TitleLabelT.setText(fatherMenu.textLib.textData[45]);
TitleLabelT.setVisible(true);
SubTitleLabelT.setText(fatherMenu.textLib.textData[39]);
SubTitleLabelT.setVisible(true);
saveData(4); startQuestCompleteBGM(); endBattleBGM(); }}if(gamePhase==18)
{
movementSpeed=0;
if(gamePhaseTimeCounter<50)
gamePhaseTimeCounter=50;
++gamePhaseTimeCounter;
if(gamePhaseTimeCounter==51)
{
placeChangeBlack.setBounds(0.0.784.362);
placeChangeBlack.setVisible(true);
placeChangeBlack_1.setBounds(0.0.784.362);
placeChangeBlack_1.setVisible(true);
TitleLabelT.setVisible(false);
SubTitleLabelT.setVisible(false);
groundArrayLabel.setVisible(false);
// Need to modify start
for(int i=0; i<325; ++i) { GiantBackGround[i].setBounds(32*(i%25),32* (int)(i/25), 32.32);
GiantBackGround[i].setIcon(new ImageIcon("resource/ground8.png"));
}
// Need to modify the end
playerX=50;
playerY=200;
// Need to modify start
placeNameLabel.setText(fatherMenu.textLib.textData[70]);
TitleLabelT.setText(fatherMenu.textLib.textData[70]);
TitleLabelT.setForeground(Color.LIGHT_GRAY);
TitleLabelT.setVisible(true);
SubTitleLabelT.setText(fatherMenu.textLib.textData[71]);
SubTitleLabelT.setForeground(Color.LIGHT_GRAY);
// Need to modify the end
SubTitleLabelT.setVisible(true);
}
if(gamePhaseTimeCounter>=100&&gamePhaseTimeCounter<=150)
{
placeChangeBlack.setBounds((int)((gamePhaseTimeCounter-100) *0.02*784), 0.784.362);
placeChangeBlack_1.setBounds((int)((gamePhaseTimeCounter-100) *0.02*784), 0.784.362);
}
if(gamePhaseTimeCounter==151)
{
startNewBattleBGM(4);// Need to be modified
placeChangeBlack.setVisible(false);
placeChangeBlack_1.setVisible(false);
gamePhaseTimeCounter=0; ++gamePhase; }}if(gamePhase==20)
{
gamePhaseTimeCounter=0;
boss=new Mob(4,bossLabel,thisMenu);// Need to be modified
bossLabel.setBounds(375.175.100.100);// Need to be modified
boss.reflash();
bossLabel.setVisible(true);
++gamePhase;
}
if(gamePhase==21)
{
if(boss.HP>0)
boss.reflash();
else
{
bossLabel.setVisible(false);
MobHPBar.setBounds(600.25.184*boss.HP/boss.MaxHP, 25);
MobHPText.setText(""+boss.HP+"/"+boss.MaxHP);
++gamePhase;
gamePhaseTimeCounter=0;
// Need to modify start
TitleLabelT.setText(fatherMenu.textLib.textData[72]);
TitleLabelT.setForeground(Color.LIGHT_GRAY);
TitleLabelT.setVisible(true);
SubTitleLabelT.setText(fatherMenu.textLib.textData[39]);
TitleLabelT.setForeground(Color.LIGHT_GRAY);
SubTitleLabelT.setVisible(true);
//saveData(4);
// It needs to be modifiedstartQuestCompleteBGM(); endBattleBGM(); }}if(gamePhase==endPhase)
{
endBattleBGM();
winMenu WM=new winMenu(thisMenu);
WM.setVisible(true);
thisMenu.setVisible(false);
map.stop();
}
if(gamePhase==-1)
{
if(boss.HP>0)
boss.reflash();
++gamePhaseTimeCounter;
if(gamePhaseTimeCounter>250)
{
endBattleBGM();
loseMenu LM=new loseMenu(thisMenu);
LM.setVisible(true);
thisMenu.setVisible(false); map.stop(); }}/ / refresh bossBar
if(boss! =null&&gamePhase%6= =3)
{
MobHead.setIcon(new ImageIcon("resource/MobHead_"+boss.MobId+".png"));
MobName.setText(""+boss.Name);
MobHPBar.setBounds(600.25.184*boss.HP/boss.MaxHP, 25);
MobHPText.setText(""+boss.HP+"/"+boss.MaxHP);
}
// The player tries to be oriented
if(attackCounter==0&&defenceCounter==0)
{
if(pressingD==1&&pressingW==0&&pressingS==0)
{
playingRole.tryingFace=0;
}
else if(pressingD==1&&pressingW==1)
{
playingRole.tryingFace=45;
}
else if(pressingW==1&&pressingA==0&&pressingD==0)
{
playingRole.tryingFace=90;
}
else if(pressingW==1&&pressingA==1)
{
playingRole.tryingFace=135;
}
else if(pressingA==1&&pressingW==0&&pressingS==0)
{
playingRole.tryingFace=180;
}
else if(pressingA==1&&pressingS==1)
{
playingRole.tryingFace=225;
}
else if(pressingS==1&&pressingA==0&&pressingD==0)
{
playingRole.tryingFace=270;
}
else if(pressingS==1&&pressingD==1)
{
playingRole.tryingFace=315;
}
}
playingRole.setFace();
humanIconContorler="resource/human_"+playingRole.face;
if(attackCounter==0&&defenceCounter==0&&(pressingW==1||pressingS==1||pressingA==1||pressingD==1))// Make a turn
{
double d_angle=(playingRole.facingAngle-playingRole.tryingFace+360) %360;//0-180 is clockwise
if(d_angle<=rotationSpeed||d_angle>=360-rotationSpeed)// Rotate
{
playingRole.facingAngle=playingRole.tryingFace;
}
else
{
if(d_angle>0&&d_angle<=180)
{
playingRole.facingAngle-=rotationSpeed;
}
else{ playingRole.facingAngle+=rotationSpeed; }}}if(attackCounter==0&&defenceCounter==0&&(pressingW==1||pressingS==1||pressingA==1||pressingD==1))// Make a move
{
++activeCounter;
playerX+=(int)(movementSpeed*Math.cos(playingRole.facingAngle*Math.PI/180));
playerY-=(int)(movementSpeed*Math.sin(playingRole.facingAngle*Math.PI/180));
checkPlayerLocation();
if(activeCounter>=10)//10Tick toggle to move picture once
{
activeCounter=0;
playingRole.lastMoveActive=(playingRole.lastMoveActive+1) %4;
}
if(playingRole.lastMoveActive==2)
humanIconContorler=humanIconContorler+'_'+0;
else if(playingRole.lastMoveActive==3)
humanIconContorler=humanIconContorler+'_'+2;
else
humanIconContorler=humanIconContorler+'_'+playingRole.lastMoveActive;
}
if(pressingJ==1&&attackCounter==0&&defenceCounter==0&&playingRole.HP>0)// Launch an attack
{
attackCounter=1;
}
if(attackCounter>0&&attackCounter<=8*attackSpeed)// Under attack
{
++attackCounter;
if(attackCounter>0&&attackCounter<=attackSpeed)
{
humanIconContorler=humanIconContorler+'_'+3;
}
else if(attackCounter<=2*attackSpeed)
{
humanIconContorler=humanIconContorler+'_'+4;
}
else if(attackCounter<=3*attackSpeed)
{
humanIconContorler=humanIconContorler+'_'+5;
}
else if(attackCounter<=4*attackSpeed)
{
humanIconContorler=humanIconContorler+'_'+6;
}
else if(attackCounter<=5*attackSpeed)
{
humanIconContorler=humanIconContorler+'_'+7;
}
else if(attackCounter<=6*attackSpeed)
{
humanIconContorler=humanIconContorler+'_'+8;
}
else if(attackCounter<=7*attackSpeed)
{
humanIconContorler=humanIconContorler+'_'+9; }}if(attackCounter==3*attackSpeed)// Complete the attack
{
playingRole.costEnergy(10);
fatherMenu.startNewSound("sweep"+Calculator.randomInt(1.3) +".wav".false.1);
playingRole.doAttack();
}
if(attackCounter>8*attackSpeed)// End hard straight
{
attackCounter=0;
}
if(defenceCooldown>0)
{
--defenceCooldown;
}
if(perfectDefenceTime>0)
{
--perfectDefenceTime;
}
if(pressingK==1&&attackCounter==0&&defenceCounter==0&&defenceCooldown==0)// Activate the defense
{
perfectDefenceTime=5;
defenceCounter=1;
playingRole.defenceStance=true;
playingRole.isBlocked=false;
}
if(defenceCounter==1)
{
if(pressingK==0)// Unblock
{
defenceCounter=0;
playingRole.defenceStance=false;
if(playingRole.isBlocked==true)
defenceCooldown=0;
else
defenceCooldown=30;
}
else
{
humanIconContorler=humanIconContorler+'_'+10;
}
}
humanIconContorler=humanIconContorler+".png";
if(boss! =null&&playingRole.HP>0)
{
if(playerY>=boss.bossY&&usingPlayerLabel==0)// The player should have covered the boss, but he didn't
{
usingPlayerLabel=1;
playerLabel[0].setBounds((int)playerX-playerWidth/2, (int)playerY-playerHeight/2, playerWidth, playerHeight);
playerLabel[1].setBounds((int)playerX-playerWidth/2, (int)playerY-playerHeight/2, playerWidth, playerHeight);
playerLabel[0].setVisible(false);
playerLabel[1].setVisible(true);
}
if(playerY<boss.bossY&&usingPlayerLabel==1)// The boss was supposed to cover the player, but it didn't
{
usingPlayerLabel=0;
playerLabel[0].setBounds((int)playerX-playerWidth/2, (int)playerY-playerHeight/2, playerWidth, playerHeight);
playerLabel[1].setBounds((int)playerX-playerWidth/2, (int)playerY-playerHeight/2, playerWidth, playerHeight);
playerLabel[0].setVisible(true);
playerLabel[1].setVisible(false);
}
}
playerLabel[usingPlayerLabel].setIcon(new ImageIcon(humanIconContorler));
playerLabel[usingPlayerLabel].setBounds((int)playerX-playerWidth/2, (int)playerY-playerHeight/2, playerWidth, playerHeight);
lblNewLabel_6.setBounds((int)playerX+(int) (25*Math.cos(playingRole.facingAngle*Math.PI/180)) -2, (int)playerY-(int) (25*Math.sin(playingRole.facingAngle*Math.PI/180)) -2.4.4);
lblNewLabel_7.setBounds((int)playerX+(int) (25*Math.cos(playingRole.tryingFace*Math.PI/180)) -2, (int)playerY-(int) (25*Math.sin(playingRole.tryingFace*Math.PI/180)) -2.4.4);
}
public void startNewBattleBGM(int bossID)
{
if(fatherMenu.settingLib.settings[1].equals("1"))
{
if(battleBGM! =null)
battleBGM.endMusic();
battleBGM=new CMusic("boss"+bossID+".wav".true.1); battleBGM.start(); }}public void endBattleBGM(a)
{
if(battleBGM! =null)
battleBGM.endMusic();
}
public void startQuestCompleteBGM(a)
{
if(questCompleteBGM! =null)
questCompleteBGM.endMusic();
questCompleteBGM=new CMusic("QuestComplete.wav".false.1); questCompleteBGM.start(); }}Copy the code
conclusion
Through the “Turnip Brave” game implementation, let me have a further understanding of swing related knowledge, the Language of Java has a deeper understanding than before.
Basic Java syntax, such as data types, operators, program flow control, and arrays, is better understood. Java is the core of the core object oriented thought, for this concept, finally realized some.
The source code for
Can pay attention to the blogger, private chat blogger free access