Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added FishGame/bin/com/mypro/base/graphics/Bitmap.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/base/graphics/Canvas.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/base/graphics/Matrix.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/base/graphics/Paint.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/base/tools/Log.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/basecomponet/JMatrix.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/constant/Constant.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/CannonManager$1.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/FishManager.class
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/GamePartInfo.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/HeadFish.class
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/ImageConfig.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/ImageManager.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/LayoutInfo.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/PathManager.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/ScoreManager$1.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/ScoreManager.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/ShoalManager.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/manager/XmlManager.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/Ammo.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/BackGround.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/DrawableAdapter.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/FishGold.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/FishInfo.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/FishingNet.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/GamingInfo.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/HighPoint.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/HundredPoint.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/fish/Fish$1.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/fish/Fish.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/model/interfaces/Button.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/threads/PicActThread.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/threads/ShotThread$1.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/threads/ShotThread.class
Binary file not shown.
Binary file not shown.
Binary file added FishGame/bin/com/mypro/tools/LogTools.class
Binary file not shown.
Binary file added FishGame/bin/com/mypro/tools/Tool.class
Binary file not shown.
159 changes: 130 additions & 29 deletions FishGame/src/com/mypro/basecomponet/AwtMainComponet.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.mypro.basecomponet;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.JFrame;

Expand All @@ -14,75 +18,172 @@
import com.mypro.model.GamingInfo;

public class AwtMainComponet{
private static Point initialClick;
private static JFrame frame;
private static MainSurface mainSurface;
private static boolean isMaximized = false;
private static Rectangle normalBounds;

private static final int TITLE_BAR_HEIGHT = 30;
private static final int BUTTON_WIDTH = 40;
private static final int BUTTON_HEIGHT = 30;

public static void main(String[] args) throws Exception {
Toolkit tool = Toolkit.getDefaultToolkit();
Dimension d = tool.getScreenSize();
JFrame frame = new JFrame();
frame = new JFrame();
GamingInfo.getGamingInfo().setGaming(true);
GamingInfo.getGamingInfo().setScreenWidth(900);
GamingInfo.getGamingInfo().setScreenHeight(600);
GamingInfo.getGamingInfo().setScreenHeight(600);
GamingInfo.getGamingInfo().setCurrentState(GamingInfo.STATE_START_SCREEN);
frame.setSize(GamingInfo.getGamingInfo().getScreenWidth(), GamingInfo.getGamingInfo().getScreenHeight());
frame.setUndecorated(true); // ȥ�����ڵ�װ��
// frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);//����ָ���Ĵ���װ�η��
// frame.setResizable(false);
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
MainSurface pane = new MainSurface();
GamingInfo.getGamingInfo().setSurface(pane);
frame.setContentPane(pane);
// frame.setAlwaysOnTop(true);
mainSurface = new MainSurface();
GamingInfo.getGamingInfo().setSurface(mainSurface);
frame.setContentPane(mainSurface);
frame.setVisible(true);

frame.addMouseListener(new MouseListener() {

@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mousePressed(MouseEvent e) {
initialClick = e.getPoint();

int x = e.getX();
int y = e.getY();
int frameWidth = frame.getWidth();

if (y < TITLE_BAR_HEIGHT) {
if (x >= frameWidth - BUTTON_WIDTH * 3 && x < frameWidth - BUTTON_WIDTH * 2) {
minimizeWindow();
return;
} else if (x >= frameWidth - BUTTON_WIDTH * 2 && x < frameWidth - BUTTON_WIDTH) {
maximizeWindow();
return;
} else if (x >= frameWidth - BUTTON_WIDTH) {
closeWindow();
return;
}
}

int currentState = GamingInfo.getGamingInfo().getCurrentState();
if (currentState == GamingInfo.STATE_START_SCREEN || currentState == GamingInfo.STATE_HELP_SCREEN) {
if (mainSurface.handleClick(x, y)) {
if (GamingInfo.getGamingInfo().getCurrentState() == GamingInfo.STATE_GAME_SCREEN) {
startGameInit();
}
return;
}
}

if(GameInitManager.getGameInitManager().isIniting()){
return ;
}
//�ȿ����ֹ������Ƿ�����Ӧ
if(!LayoutManager.getLayoutManager().onClick(e.getX(), e.getY())){
//�����ӵ�
CannonManager.getCannonManager().shot(e.getX(), e.getY());
}
}

@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub

}
});
// frame.pack();
pane.action();
/**
* ����һ���߳����첽��ʼ����Ϸ����
*/

frame.addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseMoved(MouseEvent e) {
}

@Override
public void mouseDragged(MouseEvent e) {
if (isMaximized) {
return;
}
if (initialClick != null && initialClick.y < TITLE_BAR_HEIGHT) {
int x = frame.getLocation().x + e.getX() - initialClick.x;
int y = frame.getLocation().y + e.getY() - initialClick.y;
frame.setLocation(x, y);
}
}
});

mainSurface.action();
}

private static void startGameInit() {
new Thread(new Runnable(){

public void run() {
//ʹ����Ϸ��ʼ����������ʼ����Ϸ
GameInitManager.getGameInitManager().init();
}

}).start();
}).start();
}

private static void minimizeWindow() {
frame.setState(JFrame.ICONIFIED);
}

private static void maximizeWindow() {
if (isMaximized) {
frame.setBounds(normalBounds);
isMaximized = false;
} else {
normalBounds = frame.getBounds();
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
frame.setBounds(0, 0, screenSize.width, screenSize.height);
isMaximized = true;
}
}

private static void closeWindow() {
GameInitManager.getGameInitManager().stop();
System.exit(0);
}

public static void drawTitleBar(Graphics g, int width, int height) {
g.setColor(new java.awt.Color(40, 40, 60));
g.fillRect(0, 0, width, TITLE_BAR_HEIGHT);

g.setColor(java.awt.Color.WHITE);
g.setFont(new java.awt.Font("Microsoft YaHei", java.awt.Font.BOLD, 14));
g.drawString("捕鱼游戏", 10, 20);

int buttonX = width - BUTTON_WIDTH * 3;

g.setColor(java.awt.Color.GRAY);
g.fillRect(buttonX, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
g.setColor(java.awt.Color.WHITE);
g.drawLine(buttonX + 10, 15, buttonX + BUTTON_WIDTH - 10, 15);

buttonX += BUTTON_WIDTH;
g.setColor(java.awt.Color.GRAY);
g.fillRect(buttonX, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
g.setColor(java.awt.Color.WHITE);
if (isMaximized) {
g.drawRect(buttonX + 12, 10, BUTTON_WIDTH - 24, BUTTON_HEIGHT - 20);
} else {
g.drawRect(buttonX + 10, 8, BUTTON_WIDTH - 20, BUTTON_HEIGHT - 16);
}

buttonX += BUTTON_WIDTH;
g.setColor(java.awt.Color.RED);
g.fillRect(buttonX, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
g.setColor(java.awt.Color.WHITE);
g.drawLine(buttonX + 12, 10, buttonX + BUTTON_WIDTH - 12, BUTTON_HEIGHT - 10);
g.drawLine(buttonX + BUTTON_WIDTH - 12, 10, buttonX + 12, BUTTON_HEIGHT - 10);
}

}
Loading