『仙剣奇侠伝柔情版』Javaの簡単な実現(二)
85341 ワード
『仙剣奇侠伝柔情版』Javaに基づく簡単な実現(二)
2018-12-02 by Kris
前回のGameFrame.classのウィンドウフレームの荷重が必要です:https://www.cnblogs.com/louis6575/p/10051873.html
原素材:
背景:https://www.cnblogs.com/images/cnblogs_com/louis6575/1354506/t_start0.png
新しい開始:https://www.cnblogs.com/images/cnblogs_com/louis6575/1354506/t_0.png
古い思い出:https://www.cnblogs.com/images/cnblogs_com/louis6575/1354506/t_1.png
開発チーム:https://www.cnblogs.com/images/cnblogs_com/louis6575/1354506/t_2.png
2018-12-02 by Kris
前回のGameFrame.classのウィンドウフレームの荷重が必要です:https://www.cnblogs.com/louis6575/p/10051873.html
package firstDemo;
import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
/**
* ,
* @author Louis
*
*/
//2
//2.1 ,
//JAVA , ( )、 ( )
@SuppressWarnings("serial")
public class GamePanel extends JPanel implements Runnable,KeyListener{
//
//2.2.1.
Image startImage,mengjImage,resumeImage,findxyImage,mengjToljcImage;
Image[] startButtonImages,resumeButtonImages,lxytImages,lightImages;
Image[] ToScDoorImages,ToLjcDoorImages,mengjDoorImages,scMapImages;
Image[] splgifImages,welcomeImages;
Image ljcImage,lxyImage;// ( , )
Image dialogImage;
Image[] lxyUpImages,lxyDownImages,lxyLeftImages,lxyRightImages;
BufferedImage splImage;
Image[] awsImages,henImages,ropeImages,azhuImages,chickImages,lchickImages,wcsImages;
private int start_DIST = 120,resume_DIST = 109,limUP = 240,limDOWN = 566,limRIGHT = 250,limLEFT = 10;
private int LXYX,LXYY,LXYDIR;
boolean ISLJC,ISSC;
int ToScDoorX,ToLjcDoorX,mengjDoorX,scMapX,startX,startButtonX,welcomeX,mengjX,lightX,resumeX,resumeButtonX,findxyX;
int ToScDoorY,ToLjcDoorY,mengjDoorY,scMapY,startY,startButtonY,welcomeY,mengjY,lightY,resumeY,resumeButtonY,findxyY;
int ToScDoorIndex,ToLjcDoorIndex,mengjDoorIndex,scMapIndex,startButtonIndex,resumeButtonIndex,lxytIndex,lightIndex,welcomeIndex;
boolean isStartShow,isstartButtonShow,isResumeShow,isResumeButtonShow,isLxyShow,isLjcShow,isScMapShow;
boolean isSave,isWelcome,isMengjShow,isLxytShow,isSBNH;
int lxyDir;
int ljcX,lxyX,lxytX,awsX,henX,ropeX,azhuX,chickX,lchickX,wcsX,dialogX,ChatX,splX;
int ljcY,lxyY,lxytY,awsY,henY,ropeY,azhuY,chickY,lchickY,wcsY,dialogY,ChatY,splY;
int awsIndex,henIndex,ropeIndex,azhuIndex,chickIndex,lchickIndex,wcsIndex,lxyIndex,splgifImagesIndex; //
String[] ChatMessages1,ChatMessages2,ChatMessages3;
int ChatIndex1,ChatIndex2,ChatIndex3;
boolean isChatShow1,isChatShow2,isChatShow3,isSpeedShift;//
BufferedImage ljcRedMap;//
BufferedImage scRedMap;//
private int ClothCode = 0;
private int UpEdge = 0;
private int LeftEdge = 0;
private int MoveSpeed;
// ,
public GamePanel(){ //
ToScDoorImages = new Image[6];ToLjcDoorImages = new Image[6];mengjDoorImages = new Image[6];welcomeImages = new Image[3];
scMapImages = new Image[3];lxytImages = new Image[2];lightImages = new Image[2];
startButtonImages = new Image[3];resumeButtonImages = new Image[4];splgifImages = new Image[13];
splgifImages = new Image[13];
awsImages = new Image[17];henImages = new Image[6];ropeImages = new Image[4];azhuImages = new Image[6];
chickImages = new Image[2];lchickImages = new Image[2];wcsImages = new Image[14];
lxyUpImages = new Image[8];lxyDownImages = new Image[8];lxyLeftImages = new Image[8];lxyRightImages = new Image[8];
//
isstartButtonShow = true;
isResumeButtonShow = true;
isStartShow = true;
isSBNH = true;
isMengjShow = false;
isLxytShow = true;
isResumeShow = false;
isWelcome = true;
isLxyShow = false;
isChatShow1 = false;isChatShow2 = false;isChatShow3 = false;
isSpeedShift = false;
isScMapShow = false;
isLjcShow = false;
//
File file = new File(" / /music/0.mid");
URL url = null;
try {
URI uri = file.toURI();
url = uri.toURL();
}
catch (MalformedURLException ex) {
}
AudioClip clip = Applet.newAudioClip(url);
clip.loop();
// i i
try {
// : ( (/) )、 ( java ,)
startImage = ImageIO.read(new File(" / /start0.png"));
mengjImage = ImageIO.read(new File(" / / / .png"));
mengjToljcImage = ImageIO.read(new File(" / / /0.png"));
resumeImage = ImageIO.read(new File(" / /resume.png"));
ljcImage = ImageIO.read(new File(" / / /0.png"));
dialogImage = ImageIO.read(new File(" / / /1.png"));
//splImage = ImageIO.read(new File(" / / /0.png"));
} catch (IOException e) {
e.printStackTrace();
}
for(int i = 0;i< welcomeImages.length;i++){
try {
welcomeImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
// TODO catch
e.printStackTrace();
}
}
for(int i = 0;i < lxytImages.length;i++){
try {
lxytImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
lightImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
// TODO catch
e.printStackTrace();
}
}
for(int i = 0;i < startButtonImages.length;i++){
try {
startButtonImages[i] = ImageIO.read(new File(" / /"+i+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
for(int i = 0;i < resumeButtonImages.length;i++){
try {
resumeButtonImages[i] = ImageIO.read(new File(" / /"+i+".png"));
} catch (IOException e) {
// TODO catch
e.printStackTrace();
}
}
for(int i = 0;i < scMapImages.length;i++){
try {
scMapImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
for(int i = 0;i < awsImages.length;i++){
try {
awsImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
for(int i = 0;i < henImages.length;i++){
try {
henImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
for(int i = 0;i < ropeImages.length;i++){
try {
ropeImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
for(int i = 0;i < azhuImages.length;i++){
try {
azhuImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
for(int i = 0;i < chickImages.length;i++){
try {
chickImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
for(int i = 0;i < lchickImages.length;i++){
try {
lchickImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
for(int i = 0;i < wcsImages.length;i++){
try {
wcsImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
for(int i = 0;i < lxyDownImages.length;i++){
try{ //0: 1:
if(ClothCode == 0){
lxyUpImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyDownImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyLeftImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyRightImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
}else if(ClothCode == 1){
lxyUpImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyDownImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyLeftImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyRightImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
}
} catch (IOException e) {
e.printStackTrace();
}
}
for(int i = 0;i < ToScDoorImages.length;i++){
try {
ToScDoorImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
ToLjcDoorImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
mengjDoorImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
for (int i = 0;i < splgifImages.length;i++){
try {
splgifImages[i] = ImageIO.read(new File(" / / /"+i+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
//
startX = 0;startY = 0;
resumeX = -8;resumeY = -40;
startButtonX = 250;startButtonY = 125;
resumeButtonX = 348;resumeButtonY = 240;
welcomeX = 115;welcomeY = 145;
lxytX = 450;lxytY = 450;
lightX = 400;lightY = 40;
findxyX = 0;findxyY = 0;
splX = 40;splY = 400;
ljcX = -200;ljcY = -200;
lxyX = 175;lxyY = 720;
awsX = 612;awsY=520;
henX = 740;henY = 320;ropeX = 900;ropeY = 680;azhuX = 770;azhuY = 350;
chickX=820;chickY = 350;lchickX=805;lchickY = 340;wcsX = 800;wcsY = 600;
scMapX = -200 - scMapX;ToScDoorX = 1600;ToLjcDoorX = 15;mengjDoorX = 750;
scMapY = -200 - scMapY;ToScDoorY = 990;ToLjcDoorY = 620;mengjDoorY = 500;
lxyIndex = 0;
lxyImage = lxyDownImages[lxyIndex];
ChatMessages1 = new String[] { " : , ?"," : , , ",
" : , "," : , ",
" : ? ?"," : , !"};
ChatMessages2 = new String[] { " : , , "," : , "," : , ",
" : , "," : , , "," : , , ",
" : , , "," : , !"};
ChatMessages3 = new String[] { " : , "," : , !"," : "," : , , !"," : "," : , "," : , "};
//2.2.2.
try{
ljcRedMap = ImageIO.read(new File(" / / /RedMap.png"));
}catch (IOException e) {
e.printStackTrace();
}
try {
scRedMap = ImageIO.read(new File(" / / /RedMap.png"));
} catch (IOException e) {
// TODO catch
e.printStackTrace();
}
}
//
public void paint(Graphics g){ //
super.paint(g); // , dialogImage
for(int i = 0;i < lxyDownImages.length;i++){
try{ //0: 1:
if(ClothCode == 0){
lxyUpImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyDownImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyLeftImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyRightImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
}else if(ClothCode == 1){
lxyUpImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyDownImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyLeftImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
lxyRightImages[i] = ImageIO.read(new File(" / / / /"+i+".png"));
}
} catch (IOException e) {
e.printStackTrace();
}
}
try {
findxyImage = ImageIO.read(new File(" / .png"));
} catch (IOException e1) {
// TODO catch
e1.printStackTrace();
}
if(isLjcShow){
ljcX = (this.getWidth() - lxyImage.getWidth(null))/2-lxyX;
ljcY = (this.getHeight() - lxyImage.getHeight(null))/2-lxyY;
if(ljcY >= UpEdge){
ljcY = UpEdge;
}
if(ljcY <= this.getHeight()-ljcImage.getHeight(null)){
ljcY = this.getHeight()-ljcImage.getHeight(null);
}
if(ljcX >= LeftEdge){
ljcX = LeftEdge;
}if(ljcX <= this.getWidth()-ljcImage.getWidth(null)){
ljcX = this.getWidth()-ljcImage.getWidth(null);
}
g.drawImage(ljcImage,ljcX,ljcY,this);//g
//g.drawImage(lxyRightImage,lxyX,lxyY,this); //
g.drawImage(awsImages[awsIndex],awsX + ljcX,awsY + ljcY,this);
g.drawImage(henImages[henIndex], henX + ljcX,henY + ljcY,this);
g.drawImage(ropeImages[ropeIndex],ropeX + ljcX,ropeY + ljcY,this);
g.drawImage(azhuImages[azhuIndex],azhuX + ljcX,azhuY + ljcY,this);
g.drawImage(chickImages[chickIndex],chickX + ljcX,chickY + ljcY,this);
g.drawImage(lchickImages[lchickIndex],lchickX + ljcX,lchickY + ljcY,this);
g.drawImage(wcsImages[wcsIndex],wcsX + ljcX,wcsY + ljcY,this);
g.drawImage(ToScDoorImages[ToScDoorIndex],ToScDoorX + ljcX,ToScDoorY + ljcY,this);
dialogX = (this.getWidth() - dialogImage.getWidth(null))/2;
dialogY = this.getHeight() - dialogImage.getHeight(null);
g.drawImage(lxyImage,lxyX + ljcX,lxyY + ljcY,this); //
if(isSBNH){ //
g.drawImage(mengjToljcImage,0,0,this);
}
if(isChatShow1){
g.drawImage(dialogImage,dialogX,dialogY,this);
g.setColor(Color.WHITE);
g.setFont(new Font(" ",Font.BOLD,30));
g.drawString(ChatMessages1[ChatIndex1], dialogX + 80, dialogY + 200);
//g.drawImage(lxyUpImage[lxyIndex],lxyX,lxyY,this);
//2.2. (1 +7 +1 )
//2.2.
//2.2.3.
}
else if(isChatShow2){
g.drawImage(dialogImage,dialogX,dialogY,this);
g.setColor(Color.WHITE);
g.setFont(new Font(" ",Font.BOLD,30));
g.drawString(ChatMessages2[ChatIndex2], dialogX + 80, dialogY + 200);
}
else if(isChatShow3){
g.drawImage(dialogImage,dialogX,dialogY,this);
g.setColor(Color.WHITE);
g.setFont(new Font(" ",Font.BOLD,30));
g.drawString(ChatMessages3[ChatIndex3], dialogX + 80, dialogY + 200);
}
}
//System.out.println(LXYDIR+","+LXYX+","+LXYY+isSave);
//
if(isMengjShow && Math.abs(lxyX + lxyImage.getWidth(null)/2 - (mengjDoorX + mengjDoorImages[0].getWidth(null)/2)) < 70
&& Math.abs(lxyY + lxyImage.getHeight(null) - (mengjDoorY + mengjDoorImages[0].getHeight(null)/2)) < 70){ //
isMengjShow = !isMengjShow;
lxyX = 200;lxyY = 690;
ClothCode = 0;
//3.2.3.
try {
Thread.sleep(80);
} catch (InterruptedException e) {
e.printStackTrace();
}
}else if(isLjcShow == true && Math.abs(lxyX + lxyImage.getWidth(null)/2 - (ToScDoorX + ToScDoorImages[0].getWidth(null)/2)) < 70
&& Math.abs(lxyY + lxyImage.getHeight(null) - (ToScDoorY + ToScDoorImages[0].getHeight(null)/2)) < 70){ //
isLjcShow = !isLjcShow;
isScMapShow = !isScMapShow;
lxyX = 200;lxyY = 645;
//3.2.3.
try {
Thread.sleep(80);
} catch (InterruptedException e) {
e.printStackTrace();
}
}else if(isScMapShow == true && Math.abs(lxyX +lxyImage.getWidth(null)/2 - (ToLjcDoorX + ToLjcDoorImages[0].getWidth(null)/2)) < 70
&& Math.abs(lxyY + lxyImage.getHeight(null) - (ToLjcDoorY + ToLjcDoorImages[0].getHeight(null)/2)) < 70){ //
isLjcShow = !isLjcShow;
isScMapShow = !isScMapShow;
lxyX = 1580;lxyY = 990;
//3.2.3.
try {
Thread.sleep(80);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
//System.out.println(lxyX+","+lxyY); //
//
if(isScMapShow){
scMapX = (this.getWidth() - lxyImage.getWidth(null))/2-lxyX;
scMapY = (this.getHeight() - lxyImage.getHeight(null))/2-lxyY;
if(scMapY >= UpEdge){
scMapY = UpEdge;
}
if(scMapY <= this.getHeight()-scMapImages[0].getHeight(null)){
scMapY = this.getHeight()-scMapImages[0].getHeight(null);
}
if(scMapX >= LeftEdge){
scMapX = LeftEdge;
}if(scMapX <= this.getWidth()-scMapImages[0].getWidth(null)){
scMapX = this.getWidth()-scMapImages[0].getWidth(null);
}
//System.out.println(isResumeShow+","+isLjcShow+","+isScMapShow);
g.drawImage(scMapImages[scMapIndex],scMapX,scMapY,this);
g.drawImage(ToLjcDoorImages[ToLjcDoorIndex],ToLjcDoorX + scMapX,ToLjcDoorY + scMapY,this);
g.drawImage(splgifImages[splgifImagesIndex],splX +200+ scMapX,splY + 20+scMapY,this);
g.drawImage(lxyImage,lxyX + scMapX,lxyY + scMapY,this); //
}
if(isMengjShow){
g.drawImage(mengjImage,0,0,this);
g.drawImage(lxytImages[lxytIndex],lxytX,lxytY,this);
g.drawImage(lightImages[lightIndex],lightX,lightY,this);
g.drawImage(mengjDoorImages[mengjDoorIndex],mengjDoorX,mengjDoorY,this);
g.drawImage(lxyImage,lxyX,lxyY,this);
}
if(isWelcome){
welcomeY = this.getHeight() - welcomeImages[welcomeIndex].getHeight(null);
welcomeX = (this.getWidth() - welcomeImages[welcomeIndex].getWidth(null))/2;
g.drawImage(welcomeImages[welcomeIndex],welcomeX,welcomeY,this);
}
if(isStartShow){
g.drawImage(startImage,startX,startY,this);
if(isstartButtonShow){
g.drawImage(startButtonImages[startButtonIndex],startButtonX,startButtonY,this);
}
}
if(isResumeShow){
//super.paint(g);
g.drawImage(resumeImage,resumeX,resumeY,this);
if(isResumeButtonShow){
g.drawImage(resumeButtonImages[resumeButtonIndex],resumeButtonX,resumeButtonY,this);
}
}
//g.drawImage(splImage,splX + ljcX,splY + ljcY,this);
//g.drawImage(findxyImage, findxyX, findxyY,this);
//System.out.println(findxyX+","+findxyY); //
}
//@Overridee
public void run() {
// 3.2.
while(true){
//3.2.1.
awsIndex++;henIndex++;ropeIndex++;azhuIndex++;chickIndex++;lchickIndex++;wcsIndex++;
scMapIndex++;ToScDoorIndex++;ToLjcDoorIndex++;lxytIndex++;lightIndex++;
splgifImagesIndex++;mengjDoorIndex++;
if(splgifImagesIndex > splgifImages.length - 1){
splgifImagesIndex = 0;
}
if(lxytIndex > lxytImages.length - 1){
lxytIndex = 0;
}
if(lightIndex > lightImages.length - 1){
lightIndex = 0;
}
if(ToLjcDoorIndex > ToLjcDoorImages.length-1){
ToLjcDoorIndex = 0;
}
if(mengjDoorIndex > mengjDoorImages.length - 1){
mengjDoorIndex = 0;
}
if(ToScDoorIndex > ToScDoorImages.length-1){
ToScDoorIndex = 0;
}
if(scMapIndex > scMapImages.length-1){
scMapIndex = 0;
}
if(awsIndex > awsImages.length-1){
awsIndex = 0;// :
}
if(henIndex > henImages.length-1){
henIndex = 0;// :
}
if(ropeIndex > ropeImages.length-1){
ropeIndex = 0;// :
}
if(azhuIndex > azhuImages.length-1){
azhuIndex = 0;// :
}
if(chickIndex > chickImages.length-1){
chickIndex = 0;// :
}
if(lchickIndex > lchickImages.length-1){
lchickIndex = 0;// :
}
if(wcsIndex > wcsImages.length-1){
wcsIndex = 0;// :
}
//3.2.3.
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
//3.2.2.
repaint(); // paint();
}
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
//System.out.println(" ");
//
if(isChatShow1){
// +
int KeyCode = e.getKeyCode();
if(KeyCode == KeyEvent.VK_SPACE){
ChatIndex1++;
if(ChatIndex1 > ChatMessages1.length - 1){
ChatIndex1 = 0;
isChatShow1 = !isChatShow1;
}
repaint();
}
}
else if(isChatShow2){
// +
int KeyCode = e.getKeyCode();
if(KeyCode == KeyEvent.VK_SPACE){
ChatIndex2++;
if(ChatIndex2> ChatMessages2.length - 1){
ChatIndex2 = 0;
isChatShow2 = !isChatShow2;
}
repaint();
}
}
else if(isChatShow3){
// +
int KeyCode = e.getKeyCode();
if(KeyCode == KeyEvent.VK_SPACE){
ChatIndex3++;
if(ChatIndex3> ChatMessages3.length - 1){
ChatIndex3 = 0;
isChatShow3 = !isChatShow3;
}
repaint();
}
}
else{
//
//4.2. , ( )
//4.2.1.
int KeyCode = e.getKeyCode();
//
if(KeyCode == KeyEvent.VK_SHIFT){
isSpeedShift = !isSpeedShift;
MoveSpeed *= 3;
if(MoveSpeed >= 15){
MoveSpeed = 15;
}
}else if(!isSpeedShift){
MoveSpeed = 5;
}repaint();
// , F4
if((isLxyShow && KeyCode == KeyEvent.VK_F4) || (!isStartShow && resumeButtonIndex == 0 && KeyCode == KeyEvent.VK_ENTER)){
isResumeShow = !isResumeShow;
}else if(isResumeShow && resumeButtonIndex == 1 && KeyCode == KeyEvent.VK_ENTER){
LXYX = lxyX;LXYY = lxyY;ISLJC = isLjcShow;ISSC = isScMapShow;LXYDIR = lxyDir;
isResumeShow = !isResumeShow;
System.out.println(LXYDIR+","+LXYX+","+LXYY+" "+ISLJC+" "+ISSC);
}else if(isResumeShow && resumeButtonIndex == 2 && KeyCode == KeyEvent.VK_ENTER){
lxyX = LXYX;lxyY = LXYY;lxyDir = LXYDIR;isLjcShow = ISLJC;isScMapShow = ISSC;
isResumeShow = !isResumeShow;isSave = true;
}else if(isResumeShow && resumeButtonIndex == 3 && KeyCode == KeyEvent.VK_ENTER){
System.exit(0);
}repaint();
// , , ENTER
if(!isLxyShow && startButtonIndex == 0 && KeyCode == KeyEvent.VK_ENTER){
// ,//
isStartShow = !isStartShow;
isLjcShow = !isLjcShow; //startButtonIndex == 0 ,
isLxyShow = !isLxyShow;
isWelcome = !isWelcome;
isMengjShow = !isMengjShow;
lxyX = lxytX ;lxyY = lxytY - 100;
ClothCode = 1;
}else if(isSave && isStartShow && startButtonIndex == 1 && KeyCode == KeyEvent.VK_ENTER){
lxyX = LXYX;lxyY = LXYY;lxyDir = LXYDIR;isLjcShow = ISLJC;isScMapShow = ISSC;isResumeShow = !isResumeShow;
}repaint();
// ,
if(KeyCode == KeyEvent.VK_UP){
isWelcome = false;
findxyY -= MoveSpeed;
if(isResumeShow){ //Up
isResumeButtonShow = true;
resumeButtonIndex--;
resumeButtonY -= resume_DIST;
if(resumeButtonIndex < 0){
resumeButtonY = limDOWN;
resumeButtonIndex = 3;
}
}repaint();
//
//a.
// ,
if(isLxyShow && !isResumeShow){ //
lxyY -= MoveSpeed; // ,
lxyIndex++;
System.out.println(isMengjShow);
if(lxyIndex >= lxyUpImages.length){
lxyIndex = 0;
}
lxyImage = lxyUpImages[lxyIndex];
lxyDir = KeyEvent.VK_UP;
}
// :
if(!isMengjShow){ //
int isRedX = lxyX + lxyImage.getWidth(null)/2;
int isRedY = lxyY + lxyImage.getHeight(null);
//
if(isLjcShow){
if(lxyY <= 0){
lxyY = 0;
}
if(ljcRedMap.getRGB(isRedX, isRedY) == -521461){
lxyY += MoveSpeed;
}
}else if(isScMapShow){
if(lxyY <= 0){
lxyY = 0;
}
if(scRedMap.getRGB(isRedX, isRedY) == -65536){
lxyY += MoveSpeed;
}
}repaint(); //
}
//System.out.println(lxyX+","+lxyY); //
//System.out.println(scRedMap.getRGB(isRedX, isRedY));//
}else if(KeyCode == KeyEvent.VK_DOWN){ // ,DOWN
isWelcome = false;
findxyY += MoveSpeed;
if(isResumeShow){ //DOWN
resumeButtonIndex++;
isResumeButtonShow = true;
resumeButtonY += resume_DIST;
if(resumeButtonIndex > resumeButtonImages.length - 1){
resumeButtonIndex = 0;
resumeButtonY = limUP;
}repaint();
}
if(isLxyShow && !isResumeShow){
lxyY += MoveSpeed;
lxyIndex++;
if(lxyIndex >= lxyDownImages.length){
lxyIndex = 0;
}repaint();
lxyImage = lxyDownImages[lxyIndex];
lxyDir = KeyEvent.VK_DOWN;
}repaint();
if(!isMengjShow){
int isRedX = lxyX + lxyImage.getWidth(null)/2;
int isRedY = lxyY + lxyImage.getHeight(null);
if(isLjcShow){ //
if(lxyY >= ljcImage.getHeight(null) - lxyImage.getHeight(null)){
lxyY = ljcImage.getHeight(null) - lxyImage.getHeight(null);
}
if(ljcRedMap.getRGB(isRedX, isRedY) == -521461){
lxyY -= MoveSpeed;
}
}repaint();
if(isScMapShow){ //
if(lxyY >= scMapImages[0].getHeight(null) - lxyImage.getHeight(null)){
lxyY = scMapImages[0].getHeight(null) - lxyImage.getHeight(null);
}
if(scRedMap.getRGB(isRedX, isRedY) == -65536){
lxyY -= MoveSpeed;
}
}repaint();
}
}else if(KeyCode == KeyEvent.VK_LEFT){
isWelcome = false;
findxyX -= MoveSpeed;
//LEFT
if(isStartShow){
startButtonX -= start_DIST;
startButtonIndex++;
if(startButtonIndex > startButtonImages.length-1){
startButtonIndex = 0;
startButtonX = limRIGHT;
}
}repaint();
if(isLxyShow && !isResumeShow){
lxyX -= MoveSpeed;
lxyIndex++;
if(lxyIndex >= lxyLeftImages.length){
lxyIndex = 0;
}
lxyImage = lxyLeftImages[lxyIndex];
lxyDir = KeyEvent.VK_LEFT;
}repaint();
if(!isMengjShow){
int isRedX = lxyX;
int isRedY = lxyY + lxyImage.getHeight(null);
if(isLjcShow){
if(lxyX <= LeftEdge){
lxyX = LeftEdge;
}
if(ljcRedMap.getRGB(isRedX, isRedY) == -521461){
lxyX += MoveSpeed;
}
}
if(isScMapShow){
if(lxyX <= LeftEdge){
lxyX = LeftEdge;
}
if(scRedMap.getRGB(isRedX, isRedY) == -65536){
lxyX += MoveSpeed;
}
}
repaint();
}
}else if(KeyCode == KeyEvent.VK_RIGHT){
isWelcome = false;
findxyX += MoveSpeed;
if(isStartShow){ //RIGHT
startButtonX += start_DIST;
startButtonIndex--;
if(startButtonIndex < 0){
startButtonIndex = 2;
startButtonX = limLEFT;
}
}
if(isLxyShow && !isResumeShow){
lxyX += MoveSpeed;
lxyIndex++;
if(lxyIndex >= lxyRightImages.length){
lxyIndex = 0;
}
lxyImage = lxyRightImages[lxyIndex];
lxyDir = KeyEvent.VK_RIGHT;
}
if(!isMengjShow){
int isRedX = lxyX + lxyImage.getWidth(null);
int isRedY = lxyY + lxyImage.getHeight(null);
if(isLjcShow){
if(lxyX >= ljcImage.getWidth(null) - lxyImage.getWidth(null)){
lxyX = ljcImage.getWidth(null) - lxyImage.getWidth(null);
}
if(ljcRedMap.getRGB(isRedX, isRedY) == -521461){
lxyX -= MoveSpeed;
}
}
if(isScMapShow){
if(lxyX >= scMapImages[0].getWidth(null) - lxyImage.getWidth(null)){
lxyX = scMapImages[0].getWidth(null) - lxyImage.getWidth(null);
}
if(scRedMap.getRGB(isRedX, isRedY) == -65536){
lxyX -= MoveSpeed;
}
}
repaint();
}
}
else if(KeyCode == KeyEvent.VK_SPACE){
isWelcome = false;
isSBNH = false;
if(isLjcShow){
int x11 = lxyX + lxyImage.getWidth(null)/2;
int y11 = lxyY + lxyImage.getHeight(null)/2;
int x12 = awsX + awsImages[awsIndex].getWidth(null)/2;
int y12 = awsY + awsImages[awsIndex].getHeight(null)/2;
if(lxyDir == KeyEvent.VK_LEFT && x11 > x12-50 && x11 < x12+50 && y11 > y12-50 && y11 < y12+50){
//
isChatShow1 = !isChatShow1;
repaint();
}
int x21 = lxyX+lxyImage.getWidth(null)/2;
int y21 = lxyY + lxyImage.getHeight(null)/2;
int x22 = azhuX + azhuImages[azhuIndex].getWidth(null)/2;
int y22 = azhuY + azhuImages[azhuIndex].getHeight(null)/2;
if(lxyDir == KeyEvent.VK_LEFT && x21 > x22-50 && x21 < x22+50 && y21 > y22-50 && y21 < y22+50){
//
isChatShow2 = !isChatShow2;
repaint();
}
int x31 = lxyX+lxyImage.getWidth(null)/2;
int y31 = lxyY + lxyImage.getHeight(null)/2;
int x32 = wcsX + wcsImages[wcsIndex].getWidth(null)/2;
int y32 = wcsY + wcsImages[wcsIndex].getHeight(null)/2;
if(lxyDir == KeyEvent.VK_UP && x31 > x32-50 && x31 < x32+50 && y31 > y32-50 && y31 < y32+50){
//
isChatShow3 = !isChatShow3;
repaint();
}
}
}
else if(KeyCode == KeyEvent.VK_1){
ClothCode = 0;
}else if(KeyCode == KeyEvent.VK_2){
ClothCode = 1;
}
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
原素材:
背景:https://www.cnblogs.com/images/cnblogs_com/louis6575/1354506/t_start0.png
新しい開始:https://www.cnblogs.com/images/cnblogs_com/louis6575/1354506/t_0.png
古い思い出:https://www.cnblogs.com/images/cnblogs_com/louis6575/1354506/t_1.png
開発チーム:https://www.cnblogs.com/images/cnblogs_com/louis6575/1354506/t_2.png