Sunday, June 24, 2018

Nodejs_互動式網頁app 切換ppt

互動式網頁app 切換ppt


看到數學老師邊放投影片便走路演講遇到突然要寫字怎麼辦?。
透過node.js架設伺服器,掃描qrcode 進行認證進而切換ppt即時繪圖 node.js

node.js
pdf.js
pdf.worker.js
用手機控制pdf切換 即時繪圖bug
view raw readme hosted with ❤ by GitHub
var express = require('express'),
app = express(),
http = require('http'),
server = http.createServer(app),
io = require('socket.io').listen(server);
fs = require('fs'),
server.listen(8081);
console.log('Server running');
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
function handler(request, response) {
fs.readFile('./eboard.html', function(err, data) {
if (err)
{
response.writeHead(500, {'Content-Type':'text/plain'});
return response.end('Error loading msg.html');
}
response.writeHead(200);
response.end(data);
});
}
// 連線
io.sockets.on('connection', function (socket) {
//登入初始化
socket.on('login', function(data)
{
//伺服端訊息
console.log("connected");
//宣告物件,放置訊息
var obj = new Object;
obj.name = data.name;
obj.msg = data.name + ' 已上線';
//將在前端輸入的名稱記錄下來
socket.name = data.name;
//將自己上線訊息傳給自己的網頁
socket.emit('msg', obj);
//告訴其他人你上線了
socket.broadcast.emit('msg', obj);
});
//接受畫布作業訊息
socket.on('draw', function(data){
//將畫布作業訊息傳給其他線上的人
socket.broadcast.emit('show', data);
});
//離線
socket.on('disconnect', function() {
//宣告物件,放置訊息
var obj = new Object;
obj.msg = socket.name + ' 已離開';
//通知所有人自己已經離開
io.sockets.emit('msg', obj);
});
// 偵聽 send 事件
socket.on('send', function (data) {
// 然後我們依據 data.act 做不同的動作
switch ( data.act )
{
// 這個是使用者打開手機網頁後發生的事件
case 'enter':
io.sockets.emit('get_response', data);
console.log('Sending getEnter');
break;
// 這個是使用者在手機網頁中點擊按鈕,讓電腦網頁背景變色的事件
case 'changebg':
io.sockets.emit('get_response', data);
console.log('Sending changeBg');
break;
// 這個是使用者在手機網頁中點擊按鈕,讓電腦網頁背景變色的事件
case 'changebg2':
io.sockets.emit('get_response', data);
console.log('Sending changeBg2');
break;
}
});
});
view raw test.js #nodejs hosted with ❤ by GitHub
<!document html>
<html>
<head>
<meta charset="utf-8">
<title>Nodejs - 電腦網頁</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://192.168.5.73:8081/socket.io/socket.io.js" type="text/javascript"></script>
<script src="../../build/pdf.js"></script>
<style type="text/css">
#main {
display: none;
}
</style>
<script type="text/javascript">
// 用來產生類似 GUID 的字串
function S4() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
function NewGuid() {
return (S4()+S4());
}
$(document).ready(function(){
var key = NewGuid();
console.log(key);
$("#qrcode").append("<img src='http://chart.apis.google.com/chart?chs=300x300&cht=qr&chl=http://192.168.5.73/dashboard/work2/tmp2.php?key=" + key + "&choe=UTF-8' />");
// NodeJS Server
var nodejs_server = "192.168.5.73:8081";
// 進行 connect
var socket = io.connect("http://" + nodejs_server);
// 偵聽 nodejs 事件
socket.on("get_response", function (b) {
var combine = b.key + "_" + b.act;
console.log(combine);
switch (combine) {
// 當擁有特定 KEY 的使用者打開手機版網頁,觸發 enter 事件,就會將 qrcode 隱藏,並秀出一張圖
case key + "_enter":
setTimeout(function () {
$("#qrcode").hide();
$("#main").show();
}, 500);
break;
// 當擁有特定 KEY 的使用者在手機版網頁中,觸發 changebg 事件,就會將網頁的背景顏色隨機變換
case key + "_changebg":
setTimeout(function () {
var str = "0123456789abcdef", t = "";
for (j = 0; j < 6; j++) {
t = t + str.charAt(Math.random() * str.length);
}
$("body").css("background-color", t);
$('#next').get(0).click();
}, 500);
break;
}
});
});
</script>
<script id="script">
//
// If absolute URL from the remote server is provided, configure the CORS
// header on that server.
//
var url = 'compressed.tracemonkey-pldi-09.pdf';
//
// Disable workers to avoid yet another cross-origin issue (workers need
// the URL of the script to be loaded, and dynamically loading a cross-origin
// script does not work).
//
// PDFJS.disableWorker = true;
//
// In cases when the pdf.worker.js is located at the different folder than the
// pdf.js's one, or the pdf.js is executed via eval(), the workerSrc property
// shall be specified.
//
// PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
var pdfDoc = null,
pageNum = 1,
pageRendering = false,
pageNumPending = null,
scale = 0.8,
canvas = document.getElementById('the-canvas'),
ctx = canvas.getContext('2d');
/**
* Get page info from document, resize canvas accordingly, and render page.
* @param num Page number.
*/
function renderPage(num) {
pageRendering = true;
// Using promise to fetch the page
pdfDoc.getPage(num).then(function(page) {
var viewport = page.getViewport(scale);
canvas.height = viewport.height;
canvas.width = viewport.width;
// Render PDF page into canvas context
var renderContext = {
canvasContext: ctx,
viewport: viewport
};
var renderTask = page.render(renderContext);
// Wait for rendering to finish
renderTask.promise.then(function () {
pageRendering = false;
if (pageNumPending !== null) {
// New page rendering is pending
renderPage(pageNumPending);
pageNumPending = null;
}
});
});
// Update page counters
document.getElementById('page_num').textContent = pageNum;
}
/**
* If another page rendering in progress, waits until the rendering is
* finised. Otherwise, executes rendering immediately.
*/
function queueRenderPage(num) {
if (pageRendering) {
pageNumPending = num;
} else {
renderPage(num);
}
}
/**
* Displays previous page.
*/
function onPrevPage() {
if (pageNum <= 1) {
return;
}
pageNum--;
queueRenderPage(pageNum);
}
document.getElementById('prev').addEventListener('click', onPrevPage);
/**
* Displays next page.
*/
function onNextPage() {
if (pageNum >= pdfDoc.numPages) {
return;
}
pageNum++;
queueRenderPage(pageNum);
}
document.getElementById('next').addEventListener('click', onNextPage);
/**
* Asynchronously downloads PDF.
*/
PDFJS.getDocument(url).then(function (pdfDoc_) {
pdfDoc = pdfDoc_;
document.getElementById('page_count').textContent = pdfDoc.numPages;
// Initial/first page rendering
renderPage(pageNum);
});
</script>
</head>
<body>
<div id="qrcode"></div>
<div id="main">
<div>
<button id="prev">Previous</button>
<button id="next">Next</button>
&nbsp; &nbsp;
<span>Page: <span id="page_num"></span> / <span id="page_count"></span></span>
</div>
<div>
<canvas id="the-canvas" style="border:1px solid black"></canvas>
</div>
</div>
</body>
</html>
view raw tmp.html hosted with ❤ by GitHub
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Nodejs - 手機網頁</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="author" content="patw, Patrick Wang" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://192.168.5.73:8081/socket.io/socket.io.js" type="text/javascript"></script>
<script src="../build/pdf.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// ==========================================================================================================================
// 建立 Socket IO 連線
// ==========================================================================================================================
var socket = io.connect("http://192.168.5.73:8081");
"undefined" != typeof console && console.log("user enter via mobile");
// ==========================================================================================================================
"undefined" != typeof console && console.log("enter mobile page");
socket.emit("send", {
key: "<?php echo $_GET['key'];?>",
act: "enter"
});
$("#change_btn").click(function(){
"undefined" != typeof console && console.log("send change color command");
socket.emit("send", {
key: "<?php echo $_GET['key'];?>",
act: "changebg"
});
});
$("#change_btn2").click(function(){
"undefined" != typeof console && console.log("send change color command");
socket.emit("send", {
key: "<?php echo $_GET['key'];?>",
act: "changebg2"
});
});
});
</script>
</head>
<body>
<p>打開手機網頁成功!快看看你的電腦螢幕吧!</p>
<input id="change_btn" type="button" value="控制電腦端變背景色" />
<input id="change_btn2" type="button" value="控制電腦端變背景色" />
<div>
<canvas id="the-canvas" style="border:1px solid black"></canvas>
</div>
</body>
</html>
<script>
$(document).ready(function() {
/* socket.io 相關設定 */
//連線位置與初始化
var socket = io.connect("http://192.168.5.73:8081");
//連線作業
socket.on('connect', function() {
//宣告物件,放置訊息
var obj = new Object;
obj.name = prompt('尊姓大名?');
//將輸入名稱傳到後端 node.js server 來通知其他人您已上線的訊息
socket.emit('login', obj);
});
//上線通知
socket.on('msg', function(data){
$('#member_msg').append('<div>' + data.msg + '</div>');
});
//別人畫布上的動作,呈現在我們自己的頁面上
socket.on('show', function(data){
//設定筆尖大小
$('#size').val( data.size );
ctx.lineWidth = data.size;
//繪圖
ctx.beginPath();
ctx.moveTo(data.x, data.y);
ctx.lineTo(data.new_x, data.new_y);
ctx.closePath();
ctx.stroke();
});
/* 繪圖相關設定 */
//宣告 canvas 元素
var c = document.getElementsByTagName('canvas')[0];
//設定 canvas 寬與高
c.width = 648;
c.height = 770;
//判斷畫布是否有動作的布林變數
var drawing = false;
//canvas 元素本身沒有畫作能力,僅為圖形容器,需要使用 javascript 來操作畫布
//我們須要透過 getContext() 來取得一個提供在 canvas 上畫圖的方法與屬性之「物件」
var ctx = c.getContext('2d');
//繪圖物件初始設定
ctx.lineCap = 'round';
ctx.lineJoin = 'round';
ctx.strokeStyle = '#000000';
ctx.lineWidth = 1;
//座標相關變數
var offset, x, y, new_x, new_y;
//滑鼠在畫布按下時的事件處理
$(document).on('mousedown', '#the-canvas', function(e){
e.preventDefault();
//打開可供畫圖的機制
drawing = true;
//計算相對的畫布範圍(這很重要)
offset = $(e.currentTarget).offset();
x = e.pageX - offset.left;
y = e.pageY - offset.top;
drawLine(x, y, x+1, y+1);
});
//滑鼠在畫布上按下左右時,移動的情況
$(document).on('mousemove', '#the-canvas', function(e){
e.preventDefault();
//是否開啟畫圖機制
if( drawing )
{
//計算移動後的新座標,再進行畫圖作業
new_x = e.pageX - offset.left;
new_y = e.pageY - offset.top;
drawLine(x, y, new_x, new_y);
x = new_x;
y = new_y;
}
});
//放開滑鼠鍵
$(document).on('mouseup', '#the-canvas', function(e){
e.preventDefault();
//關閉繪圖機制
drawing = false;
});
//選擇筆尖大小
$(document).on('change', '#size', function(e){
ctx.lineWidth = $(this).val();
});
//畫圖,並將繪畫座標傳給網頁上的其他使用者
function drawLine(x, y, new_x, new_y)
{
//繪圖
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(new_x, new_y);
ctx.closePath();
ctx.stroke();
//將繪畫座標透過 node.js 傳給使用者
var obj = new Object;
obj.x = x;
obj.y = y;
obj.new_x = new_x;
obj.new_y = new_y;
obj.size = $('#size').val();
socket.emit('draw', obj);
}
});
</script>
view raw tmp2.php hosted with ❤ by GitHub

資訊安全 與外掛羈絆?

外掛介紹?


以為要上台報告打太詳細囉,個人觀點拉別認真

外掛介紹與種類


記憶體修改應該一開始上課所說的屬於修改攻擊攻擊法的其中一種=而記憶體修改與外掛之間有有什麼關係,先來講講外掛有自動外掛和記憶體修改外掛和封包修改外掛,自動外掛就是像按鍵精靈,就是模擬鍵盤和滑鼠的動作不斷進行重複,像是掛在遊戲不斷定點打怪,再來就是封包修改外掛,clientserver端 在進行連線的時候,以遊戲來舉例的話,server端會給你腳色的血量和怪物的位置,然後client會取得你的血量,還是你的攻擊數值,然後在進行攻擊在這邊你可以修改封包來間接更改遊戲的數值,在遊戲裡如果lol有腳色躲在草叢裡這時候server端會發送封包給你跟你講那邊有人不要顯示
這時候你的用戶端你可以進行封包的竊聽然後再修改記憶體位置讓對面腳色顯示,因為大部分的伺服器只要你的client端發送的資料她都信,現在大部分的外掛都是按鍵精靈,和記憶體修改,封包修改與竊聽現在遊戲公司都會寫好封包加密你不知道封包在寫什麼竊聽也沒用,而最好寫的按鍵精靈,最好被遊戲擋掉也是按鍵精靈,如果一般來講你的按鍵精靈發送到遊戲裡面都是軟體級發送按鍵,就是用微軟內建的api去呼叫,api有分前台和後台,前台發送按鍵就是你視窗只能固定在最上層,而後台你就可以收在後面你的外掛還是可以持續對你得遊戲視窗發送,但是還是會被遊戲擋掉,最終辦法就是驅動級模擬按鍵winio.dll可以直接模擬鍵盤按鍵,前提你鍵盤要用ps2這樣才有效果,但是這只能可以前台,有了鍵盤按鍵,接下來就是要判斷什麼情況下你才要按下鍵盤的按鍵,你可以取得螢幕的像素點還是讀取記憶體的位置和封包竊聽來達到判斷是否要按鍵,再來來介紹這次要跟大家講的記憶體修改,因為就像我前面剛剛講的只要是用戶端講的服務器都信,當然有些服務器也會做判斷,來比對發送結果跟你執行結果來看看有沒有相符合,但是伺服器都不這麼做為什麼不這麼做呢,你一個判斷要卡幾秒,你想打一下怪物,卡個一秒這樣遊戲體驗不太好吧,所以能大多說不會多做過濾,所以記憶體修改可以做什麼事情呢,不侷限外掛,在軟體破解方面序號啊,都可以繞過去,如果反編譯能力過強的話
我們現在所打的程式都是由source code 然後編譯然後轉換成二進制檔,二進制看不懂r所以那些二進位的又會被轉為asm組合語言,什麼是組合語言就是像旁便那張圖一樣,我們用常用的呢
像是
Mov eax,1;
Cmp tmp,tmp2
Jmp xxxx








工具介紹



要怎樣觀看記憶體位置呢,有靜態分析ida和動態分析有ollydbg cheat engine


Ida可以去把你的程式碼他可以把你的執行檔裡面的執行檔機械瑪去化成流程圖讓破解者比較好分析,是意圖如下

然後再來就是ollydbg

左邊是機械瑪和asm組合語言,右邊的是暫存器等等再來就是
cheat engine:可以動態的去看你的記憶體位置和修改

這些是寫外掛的一些工具,下面來簡單示範怎樣修改記憶體裡面的

位置假設我要修改a變成1如果我是用修改器得怎樣做呢

模擬修改



程式執行後:這程式會一直跑
開啟我的cheat engin

可以看到上面已經加載了

點選左上角那個可以找尋進程 選擇你的main.exe按開啟

我們已經列印出a的變數記憶體位置

點這裡可以看到記憶體位置再來點右鍵

填入你的位置0x6ffe4c

可以發現你的變數位置在這裡現在回到這畫面

看右邊又個按鈕add address manually

輸入你的0x6ffe4c ,按下ok


這邊按右鍵選擇你的變數可以看誰在訪問你的變數現在回到你的程式繼續動作

按下後你可以看到你這邊已經有變動了

因為你的程式去訪問你的變數去做cmp現在來往上追蹤

把它紀錄下來,0040156D記住這位置回到

這邊在goto 0040156D 可以看到他跳到這裡

你仔細比對跟組合語言比對一下他把變數rbp-04這位置指向的是你的變數位置他把它移到暫存器eax 然後再cmp eax 1 比對看如果相符這邊我們就可以來做一些變動了
eax比對那邊設為0看會發生什麼事
這邊更改過後再去看你程式碼看會發生什麼可以發現

這邊
只是小小的展示,要如何要繞過遊戲防護呢,你可以進行dll injection
這些注入到目標主程式的記憶體讓目標主程式的記憶體已為他是自己的我們可以自己寫個dll再注入到遊戲裡面,在記憶體修改的方面的話每次開機的話你的記憶體都會不一樣,這樣的話你的dll可以做基址的定位為什麼要做定位呢,每次記憶體都會不一樣,像是你腳色血量,你如果位置都寫死的話你這次寫的外掛可以,位置都寫死位置到下次開機所有的位置你可能要重寫了,所以要做基址的定位
要怎樣用呢比如說你注入到遊戲的dll位置一定是固定的,假如說你這次的遊戲血量是0x1234 ,你注入到遊戲的記憶體位置是0x1000 那你的記憶體修改的位置可以寫為 0x1234-xxxx.dll = 234也就是你的位移量,你這邊的話你的位置就可以xxxx.dll+234當然系統也不會讓你這好破解,也會有一級指針,二級指針,三級指針等等
vc++寫的dll注入器+dll檔_sourcecode_在mega
這邊記憶體修改就差不多了更深入的話可以google
反外掛的原理會對遊戲進行字串的掃描,和對user mod kernel mod層那邊進行函數的攔截,破解反外掛的機制呢你可以選擇寫個驅動還是進行ssdt那邊進行函數的替換這邊太高端無法進行研究。
這些原理只能套在x86 也就是32位元下才有用。
還有另一種的方法就是虛擬機vm在虛擬機下開啟外掛和遊戲,你在外面對vm做修改這是你就可以對反外掛和遊戲上下其手,隨便你怎樣修改了。

Unity_實現2DRPG??

用了一堆Unity 開發2D遊戲


可以用觸控走路喔喔喔那詭異的步伐,是我debug用的

下載點丟到mega惹


Unity_魔術方塊教學軟體

當兵暑假可以完成哪些事情呢



拿起你的鱷魚皮小冊子,開始想辦法把魔術方塊轉成二維陣列,ㄏㄏ抽到密碼通譯兵,教官還以為我要抄密碼出去xd


,加上專題老師的要求魔術方塊教學軟體,老師看到了新聞說什麼日本教授透過手機拍照解魔術方塊,所以他想要做這個專題,還是硬接下來`,幾乎都是都是python呢,我們來用c#硬上吧xd
20141127 Taipei.py - PyCuber 用Python解魔術方塊

新增


修正一些bug,然後基於8355法去解魔術方塊
2.3實作內容
l   如何根據影像讀入魔術方塊
l   如何自動尋找魔術方塊解法
l   3D畫面呈現與動畫
l   把解法分層解法,並希望剛接觸的人也可以輕易把魔術方塊解出來
l   探討並分析,和其他人解法有何不同

三、原理與分析
3.1
讀魔術方塊顏色到電腦
將手上的魔術方塊狀態輸入到APP以便讓APP可以運算解答並用來教學,而魔術方塊顏色的讀入,可使用Unity直接引用OpenCV或者在Android封裝時順便將OpenCV包進去。但因這部份比較繁瑣,所以本專題採用簡單的圖形偵測方式,首先,把圖片進行邊緣化偵測後會得到一個白色外框矩形,(2)左方是取樣魔術方塊如(2)右邊的其中一面,圖上9個點是取樣的像素,用來判讀其顏色,就可取得魔術方塊的四個角落,再依比例就可以得到9塊區域的中心點,在對中心點做顏色的取樣,在背景雜訊不多時效果很好。
2. 色彩辨識
3.2 選擇魔術方塊解法
這邊解法使用台灣人許技江老師所發明,分為8底、3邊、5邊,而最後的5呢是基於工作區特殊的加一減一依序作左上右下或者下左上右,不管做幾次6次底層一定會回復到原先樣子,有這樣特性就可以來更換最後的五角完成魔術方塊。
3.3 自動尋解與教學
本專題的魔術方塊解答方式,以實作許技江老師所發明的8355法,8355法的特點是不用死背公式而是用理解的方式來解出魔術方塊,初學者可以快速上手,且不易忘記。


a.上層十字






b.工作區


c.底層十字
d.五角歸位
3  8355


4.魔術方塊轉換成2維陣列
       

5.魔術方塊向右旋轉2維陣列結果





3.4自動尋解:
(3)8355法的一些情形。(3c)的情況可使用(3b)工作區來進行邊塊和角塊的對調,最後的(3d)使用加一減一的算法來把最後五角歸位。
接下來就是把魔術方塊上各顏色的位置作轉換,成為比較好處理的二維陣列。一個立方空盒攤開後會有六個面,而魔術方塊為一個六面的立方體,亦可以類似地將其六面數位化。(4)為數位化的魔術方塊,其中的05數值分別代表六種顏色。
在對紅色一面如(5)所示,進行90度左右旋轉的時候,可以知道旋轉紅色面的話則會牽動到灰色區塊一併要進行旋轉,到這邊的時候魔術方塊已經可以用來判斷哪一面哪一點的顏色了。      
有了上面這些資訊,在做自動尋解的過程中,就只要先找到目標方塊在哪一面哪一點,然後把依照8355法或者其他解法,將方塊進行90度左右旋轉,把目標方塊轉至定位即可完成自動尋解這功能。





7.小方塊組成大方塊


3.5 3D畫面呈現
           在畫魔術方塊的時候我們採用Unity內建的3D矩形組合成(6)的這麼大的魔術方塊供需要273D矩形,所以只要把用先把位置弄出來,我們再依序把273D矩形放入到相對應位置,再配合3.4自動尋解中所提到的二維陣列就可以畫出一顆完整的魔術方塊。
3.6動畫的呈現
如圖6所示
程式碼去呼叫IEnumerator介面函數時,會先去執行裡面的函數,當遇到yield return 0;則暫時返回呼叫它的原先程式。Start()繼續往下做其他事情,Nowplay()則會繼續執行直到沒遇到yield return 0;則結束 IEnumerator ,將用這些函數來做畫面更新及延遲。
方塊旋轉
哪一面共包含哪九塊小方塊,這些在程式中已經配置好,如果我要對第0面進行旋轉,則第0面所牽動的九塊小方塊將會一併跟著旋轉,在旋轉的過程中,會呼叫旋轉函數並計算九個小方塊旋轉的角度,然後利用上面函數StartCoroutine來進行畫面的延遲及更新,將角度慢慢增加或減少,以呈現動畫。

Unity 實現一個LoL?

動機!?


玩了這麼久當然來要來實現一下啊
血條
區域網連線
大絕
物體碰撞
DOTA產生怪物
內建怪物自動尋路

看影片



下載點丟到mega惹

C# 實現一個2D RPG引擎?

引擎實作?


靠杯中間走不出來sorry orz

人生第一台GAMEBOY當然是玩神奇寶貝,以前就有想實現了,RPG遊戲製作大師的年代,恩~學以致用我們來實現他吧!
還沒講完,宅男們都暴動拉(也得到C#助教的契機??

大改!


繼上次的神奇寶貝RPG,這期新增的功能礙於神奇寶貝需要跟百分之百模擬畫面,所以畫面要模擬成顯示腳色周圍X軸加+10-10 Y+10-10,以往的是一開始就加載所有地圖,導致整個地圖在繪製多物件的時候會讓程式效率不足,所以腳色移動不再是真正的在FORM裡面移動是固定在中央每次鍵盤按下去只會對針對的XY軸做計算,再來傳送到繪製地圖兩個迴圈進行繪圖,大大提高程式效率,到最後還是達成了這個大改算是把之前的腳色對話、判斷是否面對面、事件等等,所有涉及到座標的都必須更改,此外還新增NPC走路只要載入特定的素材檔,開發者只要4行就可以操縱NPC走路方向,整體來說神奇寶貝RPG就是基於RPG遊戲製作大師工具而啟發的,這個專體寫到後面說是遊戲到不如說是一個RPG遊戲開發引擎,下面會來為各位做一個統整。

1.畫面變動更改物品增加與移除
2.劇情功能設定將配合下面對話功能和戰鬥畫面衍生而出劇情。
3.對話功能增加鎖按鍵(不能移動)
4.戰鬥畫面設計介面新增。
5.碰撞功能分為靜態與動態。
6.新增功能有草叢遇怪物功能,沒抓寵功能因為遊戲畫面大改導致沒有實現。
7.道館也是因為遊戲畫面大改導致沒有實現。
8.捕捉神奇寶貝功能新增
9.可以在功能欄位裡面選擇神奇寶貝並可用來與其他腳色戰鬥

我們來看圖吧!(部落格被砍了,實在懶得再拍影片


主畫面恩~不錯

三層陣列




這意味者照期中的方式來繪圖將會大大增加記憶體和CPU使用率,但如果改用期末的畫面的話將大幅提升效能,也增加了可調螢幕解析度讓遊戲畫面不再受侷限,將可以用來製作迷宮方面,不再是一下子就找到事件的地點了,使得探索大大提升畫面可玩性。


偽2.5D樹木


戰鬥功能新增介面和攻擊爆擊



草叢遭遇野生怪物



捕捉神奇寶貝



NPC對戰系統




rpg.code


using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
using WMPLib;
using System.IO;
namespace WindowsFormsApplication1
{
public class Class1
{
System.Windows.Forms.Timer aTimer;
public MP3Player backer = new MP3Player();
public int loding = 0;
public int touch;
public int plx = 560;
public int ply = 240;
public int pb1x = 0;
public int pb1y = 0;
public int orplx = 240;
public int orply = 240;
public int msx;
public int msy;
public int wallx;
public int wally;
public int u, p, r, f;
public string backroundsound;
public string size;
public int ms1_ev = 0;
public int ms2_ev = 0;
public int map1_ev = 0;
public int train;
public int face;
public int face_back;
public int touch2;
public int touch3;
public int[] max_map;
public int[] max_monster;
public int[] max_wall;
public string now_map = "Test";
public int beforex;
public int beforey;
public int INL;
public int times;
public byte lightblack = 255;
public int lightblack2 = 255;
public int map_loading = 0;
int z;
int y;
public int nowid;
public int changemaptest = 0;
public int changemaping = 0;
public int changemaping2 = 0;
System.Timers.Timer timersTimer = new System.Timers.Timer();
System.Timers.Timer timersTimer2 = new System.Timers.Timer();
/// <summary> ///////////////////////////////////////////////////////
Bitmap bmplayer = new Bitmap("pok/player.png");
Bitmap bmplayer2 = new Bitmap("pok/2.png");
Bitmap bmptmp;
Bitmap bmpman = new Bitmap("pok/man.png");
Bitmap bmpgirl = new Bitmap("pok/girl.png");
Bitmap bmp2 = new Bitmap("pok/MAP2.jpg");
Form gameform;
worldmap worldmap;
Playerparty playerparty;
PictureBox worldmapspritepb;
worldmapmonster[] map;
worldmapmonster[] monster;
worldmapmonster[] wall;
KeyEventArgs tmpe;
public int fight = 0;
public CombatGUI atack;
Image img;
Graphics device;
/// <切割圖片走圖>///////////////////////////////////////////////////////
/// public static Bitmap Resize(Bitmap originImage, Double times)
private static Bitmap Process(Bitmap originImage, int oriwidth, int oriheight, int width, int height)
{
Bitmap resizedbitmap = new Bitmap(width, height);
Graphics g = Graphics.FromImage(resizedbitmap);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.Clear(Color.Transparent);
g.DrawImage(originImage, new Rectangle(0, 0, width, height), new Rectangle(0, 0, oriwidth, oriheight), GraphicsUnit.Pixel);
return resizedbitmap;
}
public static Bitmap Resize(Bitmap originImage, Double times)
{
int width = Convert.ToInt32(originImage.Width * times);
int height = Convert.ToInt32(originImage.Height * times);
return Process(originImage, originImage.Width, originImage.Height, width, height);
}
public Bitmap TakeScreenshot(int y, int x, Bitmap bmpx, int cutx1, int cutx2, int cuty1, int cuty2, double multiple)
{
Bitmap destBitmap = new Bitmap(bmpx.Width, bmpx.Height);
Rectangle destRect = new Rectangle(0, 0, destBitmap.Width / cutx1, destBitmap.Height / cuty1); // 你的輸出範圍
Rectangle srcRect = new Rectangle(y, x, bmpx.Width / cutx1, bmpx.Height / cuty2); // 你的原圖剪裁區域
Graphics.FromImage(destBitmap).DrawImage(bmpx, destRect, srcRect, GraphicsUnit.Pixel);
return Resize(destBitmap, multiple);
}
public void AlphaBlend(Bitmap source, byte alpha, Color backColor)
{
for (int x = 0; x < source.Width; x++)
{
for (int y = 0; y < source.Height; y++)
{
Color sc = source.GetPixel(x, y);
byte R = (byte)(sc.R * alpha / 255 + backColor.R * (255 - alpha) / 255);
byte G = (byte)(sc.G * alpha / 255 + backColor.G * (255 - alpha) / 255);
byte B = (byte)(sc.B * alpha / 255 + backColor.B * (255 - alpha) / 255);
byte A = (byte)(sc.A * alpha / 255 + backColor.A * (255 - alpha) / 255);
source.SetPixel(x, y, Color.FromArgb(A, R, G, B));
}
}
}
public Class1(Form form)
{
//////////////////////////////////////////////////////////
map = new worldmapmonster[10];
monster = new worldmapmonster[10];
Bitmap bmp = new Bitmap("pok/player.png");
gameform = form;
gameform.Width = 700;
gameform.Height = 700;
gameform.BackColor = Color.White;
gameform.BackgroundImage = new Bitmap("pok/MAP.jpg");
worldmap = new worldmap(gameform);
playerparty = new Playerparty(new Point(plx, ply), TakeScreenshot(0, 0, bmp, 4, 4, 4, 4, 2), 1);
worldmapspritepb = new PictureBox();
worldmapspritepb.Width = gameform.Width;
worldmapspritepb.Height = gameform.Height;
worldmapspritepb.BackColor = Color.Transparent;
worldmapspritepb.Parent = gameform;
loding = 1;
changemap("Test.txt");
///////////////////////////////////////////////////////////
}
[DllImport("user32.dll")]//取设备场景
private static extern IntPtr GetDC(IntPtr hwnd);//返回设备场景句柄
[DllImport("gdi32.dll")]//取指定点颜色
private static extern int GetPixel(IntPtr hdc, Point p);
int tmpxx = 0;
/* private void TimerEventProcessor2(object myObject, EventArgs myEventArgs)
/ {
Point p = new Point(0,0);//取置顶点坐标
IntPtr hdc = GetDC(new IntPtr(0));//取到设备场景(0就是全屏的设备场景)
int c = GetPixel(hdc, p);//取指定点颜色
int r = (c & 0xFF);//转换R
int g = (c & 0xFF00) / 256;//转换G
int b = (c & 0xFF0000) / 65536;//转换B
if (r == 255 && g == 255 && b == 255)
{
gameform.Refresh();
changemaping2 = 1;
changemaping = 0;
draw();
}
timersTimer2.Start();
}*/
/* private void TimerEventProcessor(object myObject, EventArgs myEventArgs)
{
if (lightblack2 <= 0)
{
a = new Bitmap("cl2.jpg");
playerparty.partsprite.draw2(device, plx, ply);
lightblack2 = lightblack = 255;
worldmapspritepb.Image = TakeScreenshot(0, 0, a, 1, 1, 1, 1,360);
playerparty.partsprite.draw2(device, plx, ply);
gameform.Refresh();
timersTimer2.Start();
}
else if(lightblack2>0)
timersTimer.Start();
lightblack2 -= 5;
AlphaBlend(a, lightblack -=1, Color.Black);
worldmapspritepb.Image = TakeScreenshot(0, 0, a, 1, 1, 1, 1, 360);
}*/
public void talkface(int kind, int x)
{
if (nowid == 2)
bmptmp = bmpman;
if (nowid == 3)
bmptmp = bmpgirl;
monster[x].look(kind, monster[x].id);
monster[x].draw(device);
draw();
}
public int msty(int x)
{
return monster[x].location.Y;
}
public int npcmove(int kind, int x, int times)
{
if (nowid == 2)
bmptmp = bmpman;
if (nowid == 3)
bmptmp = bmpgirl;
max_monster[x] = updata(playerparty.partsprite.UPdata(), monster[x].UPdata(), monster[x].location.X, monster[x].location.Y, plx, ply);
if (kind == 2 && monster[x].location.Y - 40 != ply || monster[x].location.X != plx)
{
monster[x].move(kind, monster[x].id, times, max_monster[x]);
msy = monster[x].location.Y;
monster[x].draw(device);
draw();
return 1;
}
else if (kind == 1 && monster[x].location.Y + 40 != ply || monster[x].location.X != plx)
{
monster[x].move(kind, monster[x].id, times, max_monster[x]);
msy = monster[x].location.Y;
monster[x].draw(device);
draw();
return 1;
}
else
return 0;
}
public int npcmove2(int kind, int x, int times)
{
if (nowid == 2)
bmptmp = bmpman;
if (nowid == 3)
bmptmp = bmpgirl;
max_monster[x] = updata(playerparty.partsprite.UPdata(), monster[x].UPdata(), monster[x].location.X, monster[x].location.Y, plx, ply);
if (kind == 3 && monster[x].location.X - 40 != plx || monster[x].location.Y != ply)
{
monster[x].move(kind, monster[x].id, times, max_monster[x]);
msx = monster[x].location.X;
monster[x].draw(device);
worldmapspritepb.Image = img;
draw();
return 1;
}
else if (kind == 4 && monster[x].location.X + 40 != plx || monster[x].location.Y != ply)
{
monster[x].move(kind, monster[x].id, times, max_monster[x]);
msx = monster[x].location.X;
monster[x].draw(device);
worldmapspritepb.Image = img;
draw();
return 1;
}
else
return 0;
}
public void mapadd()
{
z = 0;
y = 0;
for (int i = 0; i < 50; i++)
for (int j = 0; j < 41; j++)
{
if (worldmap.maparr[i, j] == 2)
{
monster[z] = new worldmapmonster(new Point(i * 40, j * 40), TakeScreenshot(20, 64, bmpman, 3, 3, 4, 4, 2), 2);
z++;
}
if (worldmap.maparr[i, j] == 5)
{
monster[z] = new worldmapmonster(new Point(i * 40, j * 40), TakeScreenshot(20, 64, bmpgirl, 3, 3, 4, 4, 2), 3);
z++;
}
}
max_monster = new int[z];
try
{
timersTimer.Start();
}
catch { timersTimer.Stop(); }
}
///數據更新///////////////////////////////////////////////////////////
public int updata(Rectangle player, Rectangle mon, int targetx, int targety, int mex, int mey)
{
bool overlapped = player.IntersectsWith(mon);
if (overlapped == true)
{
plx = mex;
ply = mey;
msx = targetx;
msy = targety;
if (face == 4 & (msx == plx - 40) & (msx < plx) & (msy == ply))
return 1;
else if (face == 1 & (msx == plx + 40) & (msx > plx) & (msy == ply))
return 1;
else if (face == 2 & (msy == ply - 40) & (msy < ply) & (msx == plx))
return 1;
else if (face == 3 & (msy == ply + 40) & (msy > ply) & (msx == plx))
return 1;
else if ((msy != ply) & (msx != plx))
return 0;
else
return 0;
}
else
{
plx = mex;
ply = mey;
return 0;
}
}
public bool walltest()
{
if (((plx / 40) <= 50) && (worldmap.maparr[(plx / 40) + 1, ply / 40] == 5 || worldmap.maparr[(plx / 40) + 1, ply / 40] == 6 || /*worldmap.maparr[(plx / 40) + 1, ply / 40] == 2||*/ worldmap.maparr[(plx / 40) + 1, ply / 40] == 3 || worldmap.maparr[(plx / 40) + 1, ply / 40] == 1) && face == 1)
return false;
if (((plx / 40) - 1 >= 0) && (worldmap.maparr[(plx / 40) - 1, ply / 40] == 5 || worldmap.maparr[(plx / 40) - 1, ply / 40] == 6 ||/* worldmap.maparr[(plx / 40) - 1, ply / 40] == 2|| */worldmap.maparr[(plx / 40) - 1, ply / 40] == 3 || worldmap.maparr[(plx / 40) - 1, ply / 40] == 1) && face == 4)
return false;
if (((ply / 40) - 1 >= 0) && (worldmap.maparr[(plx / 40), ply / 40 - 1] == 5 || worldmap.maparr[(plx / 40), ply / 40 - 1] == 6 || /*worldmap.maparr[(plx / 40), (ply / 40) - 1] == 2||*/ worldmap.maparr[(plx / 40), (ply / 40) - 1] == 3 || worldmap.maparr[(plx / 40), (ply / 40) - 1] == 1) && face == 2)
return false;
if ((ply / 40) <= 40 && (worldmap.maparr[(plx / 40), ply / 40 + 1] == 5 || worldmap.maparr[(plx / 40), ply / 40 + 1] == 6 || /*worldmap.maparr[(plx / 40), (ply / 40) + 1] == 2|| */worldmap.maparr[(plx / 40), (ply / 40) + 1] == 3 || worldmap.maparr[(plx / 40), (ply / 40) + 1] == 1) && face == 3)
return false;
else
return true;
}
public int monst()
{
Random crandom = new Random(Guid.NewGuid().GetHashCode());
int crit = crandom.Next(1, 100);
if (worldmap.maparr[(plx / 40), (ply / 40) + 1] == 7)
{
if (crit > 95)
return 1;
else
return 0;
}
else
return 0;
}
public bool walltest2(int tmp)
{
if (((plx / 40) + 1 <= 50) && (worldmap.maparr[(plx / 40) + 1, ply / 40] == tmp && face == 1))
return false;
if (((plx / 40) - 1 >= 0) && (worldmap.maparr[(plx / 40) - 1, ply / 40] == tmp && face == 4))
return false;
if (((ply / 40) - 1 >= 0) && (worldmap.maparr[(plx / 40), (ply / 40) - 1] == tmp && face == 2))
return false;
if ((ply / 40) + 1 <= 40 && (worldmap.maparr[(plx / 40), (ply / 40) + 1] == tmp && face == 3))
return false;
else
return true;
}
/// <shark視窗震動>
public void shock()
{
Point now_p = gameform.Location;
Random r = new Random();
for (int i = 0; i < 10; i++)
{
Point new_p = new Point(now_p.X + r.Next(-10, 10), now_p.Y + r.Next(-10, 10)); //新的位置
gameform.Location = new_p;
Thread t1 = new Thread(MyBackgroundTask2);
t1.Start();
t1.Join();
gameform.Location = now_p; //還原位置
}
}
/// <summary>
/// monst事件
/// </summary>
///
int pok_length;
string all_pok;
int item;
string[] pokarr = new string[12];
private void check_pok()
{
StreamReader sr = new StreamReader(@"pok.txt");
string a;
//===逐行讀取,直到檔尾===
item = 0;
while (!sr.EndOfStream)
{
a = sr.ReadLine();
string[] strArray = a.Split(',');
for (int i = 0; i < strArray.Length; i++) //透過迴圈將陣列值取出 也可用foreach
{
pokarr[item] = strArray[i].ToString();
item++;
}
pok_length = strArray.Length;
}
bmplayer = new Bitmap("pok/" + Convert.ToString(Convert.ToInt32(pokarr[((Convert.ToInt32(pokarr[0]) + 1) * 2)]) + 10) + ".png");
sr.Close();
}
public void ms1()
{
gameform.Hide();
atack = new CombatGUI();
check_pok();
atack.f1 = TakeScreenshot(0, 0, bmplayer, 1, 1, 1, 1, 2);
bmplayer2 = new Bitmap("pok/20.png");
atack.now_monname = "20";
atack.f2 = TakeScreenshot(0, 0, bmplayer2, 1, 1, 1, 1, 2);
atack.train = 1;
atack.Show();
fight = 1;
ms1_ev = 1;
atack.train = 1;
touch2 = 0;
}
public void ms2()
{
gameform.Hide();
atack = new CombatGUI();
check_pok();
atack.f1 = TakeScreenshot(0, 0, bmplayer, 1, 1, 1, 1, 2);
Random crandom = new Random(Guid.NewGuid().GetHashCode());
int crit = crandom.Next(0, 10);
bmplayer2 = new Bitmap("pok/" + Convert.ToString(crit) + ".png");
atack.now_monname = Convert.ToString(crit);
atack.bmplayer3 = bmplayer2;
atack.f2 = TakeScreenshot(0, 0, atack.bmplayer3, 1, 1, 1, 1, 2);
atack.Show();
fight = 1;
atack.train = 0;
touch2 = 0;
}
public void ms3()
{
gameform.Hide();
atack = new CombatGUI();
check_pok();
atack.f1 = TakeScreenshot(0, 0, bmplayer, 1, 1, 1, 1, 2);
bmplayer2 = new Bitmap("pok/011.png");
atack.now_monname = "011";
atack.f2 = TakeScreenshot(0, 0, bmplayer2, 1, 1, 1, 1, 2);
atack.train = 1;
atack.Show();
fight = 1;
ms2_ev = 1;
atack.train = 1;
touch2 = 0;
}
public void map1()
{
if (now_map == "Test.txt")
{
beforex = plx;
beforey = ply;
plx = 80;
ply = 120;
changemap("Test2.txt");
}
else if (now_map == "Test2.txt")
{
plx = beforex;
ply = beforey;
changemap("Test.txt");
}
}
public void map2()
{
if (now_map == "Test.txt")
{
beforex = plx;
beforey = ply;
plx = 960;
ply = 400;
changemap("Test3.txt");
}
else if (now_map == "Test3.txt")
{
plx = beforex;
ply = beforey;
changemap("Test.txt");
}
}
public void playernewpoint(int x, int y)
{
playerparty.partsprite.location = new Point(x, y);
}
public void handlekeypress(KeyEventArgs e)
{
tmpe = e;
// Thread t1 = new Thread(MyBackgroundTask);
// t1.Start();
for (int i = 0; i < z; i++)
{
if (plx + 40 == monster[i].location.X || plx - 40 == monster[i].location.X || ply + 40 == monster[i].location.Y || ply - 40 == monster[i].location.Y)
max_monster[i] = updata(playerparty.partsprite.UPdata(), monster[i].UPdata(), monster[i].location.X, monster[i].location.Y, plx, ply);
}
if (e.KeyCode == Keys.Right)
{
face = 1;
if ((plx + 40 != msx || ply != msy) && walltest())
{
plx += 40; playerparty.partsprite.move(plx, ply, e, 1, 1);
// worldmapspritepb.Location = new Point(worldmapspritepb.Location.X - 50, worldmapspritepb.Location.Y);
if (monst() == 1)
{ ms2(); }
}
else
{
if (walltest() == false)
backer.Play("sound/wall.wav"); handlekeypress2(e);
}
}
if (e.KeyCode == Keys.Left)
{
face = 4;
if ((plx - 40 != msx || ply != msy) && walltest())
{
plx -= 40; playerparty.partsprite.move(plx, ply, e, 1, 4);
// worldmapspritepb.Location = new Point(worldmapspritepb.Location.X + 50, worldmapspritepb.Location.Y);
if (monst() == 1)
{ ms2(); }
}
else
{
if (walltest() == false)
backer.Play("sound/wall.wav"); handlekeypress2(e);
}
}
if (e.KeyCode == Keys.Up)
{
face = 2;
if ((plx != msx || ply - 40 != msy) && walltest())
{
ply -= 40;
playerparty.partsprite.move(plx, ply, e, 1, 2);
// worldmapspritepb.Location = new Point(worldmapspritepb.Location.X , worldmapspritepb.Location.Y+50);
if (monst() == 1)
{ ms2(); }
}
else
{
if (walltest() == false)
backer.Play("sound/wall.wav"); handlekeypress2(e);
}
}
if (e.KeyCode == Keys.Down)
{
face = 3;
if ((plx != msx || ply + 40 != msy) && walltest())
{
ply += 40; playerparty.partsprite.move(plx, ply, e, 1, 3);
// worldmapspritepb.Location = new Point(worldmapspritepb.Location.X, worldmapspritepb.Location.Y -50);
if (monst() == 1)
{ ms2(); }
}
else
{
if (walltest() == false)
backer.Play("sound/wall.wav"); handlekeypress2(e);
}
}
if (walltest2(4) == false)
map1();
if (walltest2(8) == false)
map2();
draw();
// t1.Join();
}
public void handlekeypress2(KeyEventArgs e)
{
if (e.KeyCode == Keys.Right)
{ playerparty.partsprite.move(plx, ply, e, 1, 5); }
else if (e.KeyCode == Keys.Up)
{ playerparty.partsprite.move(plx, ply, e, 1, 6); }
else if (e.KeyCode == Keys.Left)
{ playerparty.partsprite.move(plx, ply, e, 1, 7); }
else if (e.KeyCode == Keys.Down)
{ playerparty.partsprite.move(plx, ply, e, 1, 8); }
draw();
}
/// < MyBackgroundTask延遲函數>
void MyBackgroundTask()
{
lightblack2 = lightblack = 255;
changemaping = 0;
changemaping2 = 1;
if (changemaping2 == 1)
{
timersTimer.Stop();
draw();
changemaping2 = 1;
}
}
void MyBackgroundTask2()
{
Thread.Sleep(10);
}
/// <View設定隱藏顯示>
public void View(bool sw)
{
if (sw == true)
gameform.Hide();
else
gameform.Show();
}
public void changemap(string mapname)
{
backer.Play("sound/changemap.wav");
now_map = mapname;
worldmap.inmap(mapname);
mapadd();
changemaptest = 1;
times = 0;
changemaping = 0;
}
private Image CutImage(Image SourceImage, Point StartPoint, Rectangle CutArea)
{
try
{
Bitmap NewBitmap = new Bitmap(CutArea.Width, CutArea.Height);
Graphics tmpGraph = Graphics.FromImage(NewBitmap);
tmpGraph.DrawImage(SourceImage, CutArea, StartPoint.X, StartPoint.Y, CutArea.Width, CutArea.Height, GraphicsUnit.Pixel);
tmpGraph.Dispose();
return NewBitmap;
}
catch { return null; }
}
public void draw()
{
img = new Bitmap(400 + plx, 400 + ply);
device = Graphics.FromImage(img);
for (int i = 0; i < z; i++)
{
monster[i].draw(device);
}
for (int i = 0; i < y; i++)
{
wall[i].draw(device);
}
worldmap.drawmap(device, plx / 40, ply / 40);
playerparty.partsprite.draw2(device, plx, ply);
worldmap.drawmap2(device);
img = CutImage(img, new Point(plx - 320, ply - 280), new Rectangle(0, 0, 800, 800));
worldmapspritepb.Image = img;
gameform.Refresh();
GC.Collect();//清除new物件 重要會吃記憶體
}
}
class worldmap
{
private static Bitmap Process(Bitmap originImage, int oriwidth, int oriheight, int width, int height)
{
Bitmap resizedbitmap = new Bitmap(width, height);
Graphics g = Graphics.FromImage(resizedbitmap);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.Clear(Color.Transparent);
g.DrawImage(originImage, new Rectangle(0, 0, width, height), new Rectangle(0, 0, oriwidth, oriheight), GraphicsUnit.Pixel);
return resizedbitmap;
}
public static Bitmap Resize(Bitmap originImage, Double times)
{
int width = Convert.ToInt32(originImage.Width * times);
int height = Convert.ToInt32(originImage.Height * times);
return Process(originImage, originImage.Width, originImage.Height, width, height);
}
public Bitmap TakeScreenshot(int y, int x, Bitmap bmpx, int cutx1, int cutx2, int cuty1, int cuty2, double multiple)
{
Bitmap destBitmap = new Bitmap(bmpx.Width, bmpx.Height);
Rectangle destRect = new Rectangle(0, 0, destBitmap.Width / cutx1, destBitmap.Height / cuty1); // 你的輸出範圍
Rectangle srcRect = new Rectangle(y, x, bmpx.Width / cutx1, bmpx.Height / cuty2); // 你的原圖剪裁區域
Graphics.FromImage(destBitmap).DrawImage(bmpx, destRect, srcRect, GraphicsUnit.Pixel);
return Resize(destBitmap, multiple);
}
public worldmap(Form form)
{
}
public float[,] maparr;
public int tmpx;
public int tmpy;
public MP3Player backer = new MP3Player();
public int loading = 0;
public int loading2 = 0;
public void inmap(string mapname)
{
int txtLength = 0, i = 0;
string s1;
FileStream fs = new FileStream(mapname, FileMode.Open);
StreamReader sr = new StreamReader(fs, Encoding.Default);
/* 取得行數 */
s1 = sr.ReadLine();
while (s1 != null)
{
txtLength++;
s1 = sr.ReadLine();
}
fs.Position = 0;
/* 取得資料並放入陣列 */
string[] s2 = new string[2];
float[,] txtValue = new float[50, 41];
maparr = new float[50, 41];
s1 = sr.ReadLine();
while (s1 != null)
{
s2 = s1.Split(' ');
for (int j = 0; j < 50; j++)
txtValue[j, i] = float.Parse(s2[j]);
i++;
s1 = sr.ReadLine();
}
for (int x = 0; x < 50; x++)
for (int y = 0; y < 41; y++)
{
maparr[x, y] = txtValue[x, y];
}
sr.Close();
fs.Close();
}
public void drawmap(Graphics device, int plx, int ply)
{
Bitmap bmp2 = new Bitmap("pok/MAP.jpg");
Bitmap bmp3 = new Bitmap("pok/MAP2.jpg");
Bitmap bmp4 = new Bitmap("pok/MAP5.png");
Bitmap bmp5 = new Bitmap("pok/MAP6.png");
Bitmap bmp6 = new Bitmap("pok/cl.jpg");
Bitmap bmp7 = new Bitmap("pok/pokemcen.png");
try
{
loading = 0;
// txtValue陣列是從記事本取得的二維陣列,也就是您要的結果
/////////////////////
//繪畫網格方便設定物件
for (int x = plx - 9; x < plx + 9; x++)
{
for (int y = ply - 9; y < ply + 9; y++)
{
if (x < 0 || y < 0 || x >= 50 || y >= 40)
continue;
if (maparr[x, y] == 7)
{
if (x == plx && y == ply + 1 && maparr[plx, ply + 1] == 7)
{
device.DrawImage(TakeScreenshot(0, 0, bmp5, 1, 1, 1, 1, 1), x * 40, y * 40);
}
else
device.DrawImage(TakeScreenshot(0, 0, bmp4, 1, 1, 1, 1, 1), x * 40, y * 40);
}
if (maparr[x, y] == 1)
{
device.DrawImage(TakeScreenshot(0, 0, bmp6, 1, 1, 1, 1, 2), x * 40, y * 40);
}
if (maparr[x, y] == 6)
{
device.DrawImage(TakeScreenshot(0, 0, bmp7, 1, 1, 1, 1, 1.2), x * 40, y * 40);
}
if (maparr[x, y] == 3)
{
device.DrawImage(TakeScreenshot(0, 0, bmp3, 1, 1, 1, 1, 2), x * 40, y * 40);
}
if (y > 1)
if (maparr[x, y + 1] == 3 && maparr[x, y - 1] == 3)
{
tmpx = plx; tmpy = ply + 1;
continue;
}
}
// Pen pen = new Pen(Color.Green);
}
loading = 1;
}
catch
{ }
}
public void drawmap2(Graphics device)
{
loading = 0;
Bitmap bmp3 = new Bitmap("pok/MAP2.jpg");
for (int i = tmpy; i < tmpy+10; i++)
{
if(i<40)
if (maparr[tmpx, i] == 3)
{
device.DrawImage(TakeScreenshot(0, 0, bmp3, 1, 1, 1, 1, 2), tmpx * 40, i * 40);
}
}
loading = 1;
}
public void delatemap()
{
maparr = null;
}
}
}
class worldmapsprite
{
Bitmap bmpman = new Bitmap("pok/man.png");
Bitmap bmpgirl = new Bitmap("pok/girl.png");
Bitmap bmpt;
Bitmap bmptmp;
Random crandom = new Random(Guid.NewGuid().GetHashCode());
public PictureBox pb1 = new PictureBox();
Bitmap bmp = new Bitmap("pok/player.png");
public Point location;
public Image image;
int plx = 0;
int ply = 0;
int rl = 0;
int rl2 = 0;
int race;
int height;
int width;
public int id;
int back;
System.Timers.Timer tmr = new System.Timers.Timer(200);
int cutx = 0, cuty = 0, orx = 0, ory = 0, chx = 0, chy = 0;
private static Bitmap Process(Bitmap originImage, int oriwidth, int oriheight, int width, int height)
{
Bitmap resizedbitmap = new Bitmap(width, height);
Graphics g = Graphics.FromImage(resizedbitmap);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.Clear(Color.Transparent);
g.DrawImage(originImage, new Rectangle(0, 0, width, height), new Rectangle(0, 0, oriwidth, oriheight), GraphicsUnit.Pixel);
return resizedbitmap;
}
public static Bitmap Resize(Bitmap originImage, Double times)
{
int width = Convert.ToInt32(originImage.Width * times);
int height = Convert.ToInt32(originImage.Height * times);
return Process(originImage, originImage.Width, originImage.Height, width, height);
}
public Bitmap TakeScreenshot(int y, int x, Bitmap bmpx, int cutx1, int cutx2, int cuty1, int cuty2, double multiple)
{
Bitmap destBitmap = new Bitmap(bmpx.Width, bmpx.Height);
Rectangle destRect = new Rectangle(0, 0, destBitmap.Width / cutx1, destBitmap.Height / cuty1); // 你的輸出範圍
Rectangle srcRect = new Rectangle(y, x, bmpx.Width / cutx1, bmpx.Height / cuty2); // 你的原圖剪裁區域
Graphics.FromImage(destBitmap).DrawImage(bmpx, destRect, srcRect, GraphicsUnit.Pixel);
return Resize(destBitmap, multiple);
}
public Rectangle UPdata()
{//33 48
Rectangle p1 = pb1.ClientRectangle;
pb1.Location = new Point(plx, ply);
p1.Offset(pb1.Location);
p1.Location = new Point(location.X, location.Y);
return p1;
}
public void UPdata2(int plxx, int plyy)
{//33 48
plx = plxx;
ply = plyy;
}
void MyBackgroundTask()
{
Thread.Sleep(20);
}
public worldmapsprite(Point location, Image image, int id)
{
pb1.Size = new Size(80, 80);
this.location = location;
this.image = image;
this.id = id;
width = image.Width;
height = image.Height;
tmr.Start();
}
void UP()
{//48 64 16
//player
if (race == 1) { cutx = 48; cuty = 0; orx = 3; ory = 3; chy = 4; chx = 4; bmpt = bmp; }
if (rl == 1)
{
image = TakeScreenshot(cutx * 0, cuty, bmpt, orx, ory, chx, chy, 2);
}
else if (rl == 0) { image = TakeScreenshot(cutx * 1, cuty, bmpt, orx, ory, chx, chy, 2); }
}
void DOWN()
{
if (race == 1) { cutx = 48; cuty = 64; orx = 3; ory = 3; chy = 4; chx = 4; bmpt = bmp; }
if (rl == 1)
{
image = TakeScreenshot(cutx * 0, cuty, bmpt, orx, ory, chx, chy, 2);
}
else if (rl == 0) { image = TakeScreenshot(cutx * 1, cuty, bmpt, orx, ory, chx, chy, 2); }
}
void RIGHT()
{
if (race == 1) { cutx = 48; cuty = 16; orx = 3; ory = 3; chy = 4; chx = 4; bmpt = bmp; }
if (rl == 1)
{
image = TakeScreenshot(cutx * 0, cuty * 2, bmpt, orx, ory, chx, chy, 2);
}
else if (rl == 0) { image = TakeScreenshot(cutx * 1, cuty * 2, bmpt, orx, ory, chx, chy, 2); }
}
void LEFT()
{
if (race == 1) { cutx = 48; cuty = 16; orx = 3; ory = 3; chy = 4; chx = 4; bmpt = bmp; }
if (rl == 1)
{
image = TakeScreenshot(cutx * 0, cuty * 6, bmpt, orx, ory, chx, chy, 2);
}
else if (rl == 0) { image = TakeScreenshot(cutx * 1, cuty * 6, bmpt, orx, ory, chx, chy, 2); }
}
public void look(int face, int id)
{
if (id == 2)
bmptmp = bmpman;
else if (id == 3)
bmptmp = bmpgirl;
if (face == 2)
image = TakeScreenshot(20, 1, bmptmp, 3, 3, 4, 4, 2);
else if (face == 3)
image = TakeScreenshot(21, 32, bmptmp, 3, 3, 4, 4, 2);
else if (face == 1)
image = TakeScreenshot(20, 64, bmptmp, 3, 3, 4, 4, 2);
else if (face == 4)
image = TakeScreenshot(21, 96, bmptmp, 3, 3, 4, 4, 2);
}
public void move(int face, int id, int times, int touch)
{
if (rl2 == 0) { rl2 = 1; }
else if (rl2 == 1)
{ rl2 = 0; }
if (id == 2)
bmptmp = bmpman;
else if (id == 3)
bmptmp = bmpgirl;
if (face == 1)
{
location.Y += 40;
if (rl2 == 0)
image = TakeScreenshot(1, 64, bmptmp, 3, 3, 4, 4, 2);
else if (rl2 == 1)
{
image = TakeScreenshot(45, 64, bmptmp, 3, 3, 4, 4, 2);
}
}
else if (face == 2)
{
location.Y -= 40;
if (rl2 == 0)
image = TakeScreenshot(1, 1, bmptmp, 3, 3, 4, 4, 2);
else if (rl2 == 1)
{
image = TakeScreenshot(45, 1, bmptmp, 3, 3, 4, 4, 2);
}
}
else if (face == 3)
{
location.X -= 40;
if (rl2 == 0)
image = TakeScreenshot(1, 96, bmptmp, 3, 3, 4, 4, 2);
else if (rl2 == 1)
{
image = TakeScreenshot(45, 96, bmptmp, 3, 3, 4, 4, 2);
}
}
else if (face == 4)
{
location.X += 40;
if (rl2 == 0)
image = TakeScreenshot(1, 32, bmptmp, 3, 3, 4, 4, 2);
else if (rl2 == 1)
{
image = TakeScreenshot(45, 32, bmptmp, 3, 3, 4, 4, 2);
}
}
}
public void move(int x, int y, KeyEventArgs e, int inrace, int face)
{
GC.Collect();//清除new物件 重要會吃記憶體
race = inrace;
if (e.KeyCode == Keys.Up)
{
UP();
if (rl == 0) { rl = 1; }
else if (rl == 1)
{ rl = 0; }
}
else if (e.KeyCode == Keys.Down)
{
DOWN();
if (rl == 1) { rl = 0; }
else if (rl == 0)
{ rl = 1; }
}
else if (e.KeyCode == Keys.Left)
{
LEFT();
if (rl == 0) { rl = 1; }
else if (rl == 1)
{ rl = 0; }
}
else if (e.KeyCode == Keys.Right)
{
RIGHT();
if (rl == 0) { rl = 1; }
else if (rl == 1)
{ rl = 0; }
}
back = face;
if (back == 5)
{ cutx = 48; cuty = 16; orx = 3; ory = 3; chy = 4; chx = 4; bmpt = bmp; image = TakeScreenshot(20, cuty * 2, bmpt, orx, ory, chx, chy, 2); }
else if (back == 6)
{ cutx = 48; cuty = 0; orx = 3; ory = 3; chy = 4; chx = 4; bmpt = bmp; image = TakeScreenshot(20, cuty, bmpt, orx, ory, chx, chy, 2); }
else if (back == 7)
{ cutx = 48; cuty = 16; orx = 3; ory = 3; chy = 4; chx = 4; bmpt = bmp; image = TakeScreenshot(20, cuty * 6, bmpt, orx, ory, chx, chy, 2); }
else if (back == 8)
{ cutx = 48; cuty = 16; orx = 3; ory = 3; chy = 4; chx = 4; bmpt = bmp; bmpt = bmp; image = TakeScreenshot(20, cuty * 4, bmpt, orx, ory, chx, chy, 2); }
pb1.Location = new Point(x, y);
location.X = x;
location.Y = y;
}
public void draw(Graphics device)
{
try
{
device.DrawImage(image, location);
}
catch { }
}
public void draw2(Graphics device, int plx, int ply)
{
device.DrawImage(image, plx, ply);
}
public PictureBoxSizeMode StretchImage { get; set; }
}
class worldmapmonster : worldmapsprite
{
public bool isstatic;
public worldmapmonster(Point location, Image image, int id)
: base(location, image, id)
{
isstatic = true;
}
}
class Playerparty
{
public worldmapsprite partsprite;
public Playerparty(Point location, Image image, int id)
{
partsprite = new worldmapsprite(location, image, id);
}
}
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public class MP3Player
{
public void Play(string FilePath)
{
mciSendString("close all", "", 0, 0);
mciSendString("open " + FilePath + " alias media", "", 0, 0);
mciSendString("play media", "", 0, 0);
}
public void Pause()
{
mciSendString("pause media", "", 0, 0);
}
public void Stop()
{
mciSendString("close media", "", 0, 0);
}
[DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
private static extern int mciSendString(
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,
int hwndCallback
);
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
using WMPLib;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class CombatGUI : Form
{
int Poison = 3;
MP3Player back = new MP3Player();
public Bitmap bmplayer3 = new Bitmap("pok/2.png");
public Bitmap bmplayer4 = new Bitmap("pok/1.png");
public string now_monname;
int catching;
public int train = 0;
int enhp = (2000 / 200);
int plhp = (2000 / 200);
int plattack_now = 0;
int plattack = 0;
int enattack_now = 0;
int enattack = 0;
public int time;
public int win;
public int outside;
public double tmpx;
public double tmpy;
public int enytmpx;
public int enytmpy;
int catcho;
int sleeptime = 0;
int sh1;
int sh2;
public int over = 0;
int locked = 0;
public int over2()
{
return over;
}
void MyBackgroundTask()
{
radioButton1.Enabled = false;
radioButton2.Enabled = false;
radioButton3.Enabled = false;
radioButton4.Enabled = false;
Thread.Sleep(20000);
Environment.Exit(Environment.ExitCode);
}
public string backroundsound;
public Bitmap f1, f2;
public CombatGUI()
{
InitializeComponent();
}
private static Bitmap Process(Bitmap originImage, int oriwidth, int oriheight, int width, int height)
{
Bitmap resizedbitmap = new Bitmap(width, height);
Graphics g = Graphics.FromImage(resizedbitmap);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.Clear(Color.Transparent);
g.DrawImage(originImage, new Rectangle(0, 0, width, height), new Rectangle(0, 0, oriwidth, oriheight), GraphicsUnit.Pixel);
return resizedbitmap;
}
public static Bitmap Resize(Bitmap originImage, Double times)
{
int width = Convert.ToInt32(originImage.Width * times);
int height = Convert.ToInt32(originImage.Height * times);
return Process(originImage, originImage.Width, originImage.Height, width, height);
}
public Bitmap TakeScreenshot(int y, int x, Bitmap bmpx, int cutx1, int cutx2, int cuty1, int cuty2, double multiple)
{
Bitmap destBitmap = new Bitmap(bmpx.Width, bmpx.Height);
Rectangle destRect = new Rectangle(0, 0, destBitmap.Width / cutx1, destBitmap.Height / cuty1); // 你的輸出範圍
Rectangle srcRect = new Rectangle(y, x, bmpx.Width / cutx1, bmpx.Height / cuty2); // 你的原圖剪裁區域
Graphics.FromImage(destBitmap).DrawImage(bmpx, destRect, srcRect, GraphicsUnit.Pixel);
return Resize(destBitmap, multiple);
}
private void CombatGUI_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Z:
if (locked == 1 && catching == 0)
{
change_if();
}
break;
/* case Keys.Down:
radioButton1.Focus();
radioButton5.Focus();
break;
case Keys.Up:
radioButton4.Focus();
radioButton8.Focus();
break;*/
}
}
void MyBackgroundTask2()
{
Thread.Sleep(sleeptime);
}
private void CombatGUI_Load(object sender, EventArgs e)
{
// 初始化画板
Bitmap image = new Bitmap(pictureBox1.ClientSize.Width, pictureBox1.ClientSize.Height);
// 获取背景层
Bitmap bg = (Bitmap)pictureBox1.BackgroundImage;
Bitmap bmplayer2 = new Bitmap("pok/ball.png");
// 初始化画布
Bitmap canvas = new Bitmap(pictureBox1.ClientSize.Width, pictureBox1.ClientSize.Height);
// 初始化图形面板
Graphics g = Graphics.FromImage(image);
Graphics gb = Graphics.FromImage(canvas);
pictureBox2.BackgroundImage = canvas; // 设置为背景层
pictureBox2.CreateGraphics().DrawImage(canvas, 0, 0);
bg = new Bitmap("pok/back.png");
DRAWIMAGEXX(gb, TakeScreenshot(0, 0, bmplayer3, 1, 1, 1, 1, 2), EnemyPB1.Location.X, EnemyPB1.Location.Y, 1, 1);
this.Focus();
wmp2.URL = "sound/battle.mp3";
wmp2.Ctlcontrols.play();
PartyPB1.Image = f1;
EnemyPB1.Image = f2;
enytmpx = EnemyPB1.Location.X;
enytmpy = EnemyPB1.Location.Y;
// ModifyProgressBarColor.SetState(progressBar1, 3);
// ModifyProgressBarColor.SetState(progressBar2, 3);
// ModifyProgressBarColor.SetState(progressBar3, 1);
// ModifyProgressBarColor.SetState(progressBar4, 1);
enemyAttackTimer.Enabled = true;
Playerattacttimer.Enabled = true;
if (train == 1)
radioButton2.Enabled = false;
else
radioButton2.Enabled = true;
locked = 1;
label4.Text = "what to do now?";
check_pok();
}
private void enemyAttackTimer_Tick_1(object sender, EventArgs e)
{
}
private void Playerattacttimer_Tick(object sender, EventArgs e)
{
}
void change_if()
{
Random crandom = new Random(Guid.NewGuid().GetHashCode());
int crit = crandom.Next(1, 10);
int crit2 = crandom.Next(1, 100);
if (radioButton1.Checked == true)
{
label4.Visible = false;
radioButton1.Enabled = false;
radioButton2.Enabled = false;
radioButton3.Enabled = false;
radioButton4.Enabled = false;
radioButton5.Visible = true;
radioButton6.Visible = true;
radioButton7.Visible = true;
radioButton8.Visible = true;
locked = 0;
}
else if (radioButton5.Checked == true || radioButton6.Checked == true)
{
///////////////////////////////////////////////////////////////////
if (crit < 2)
{
wmp3.URL = "sound/lit.wav";
label4.Text = "Player attack!";
}
if (crit >= 2 && crit < 8)
{
wmp3.URL = "sound/knf.wav";
label4.Text = "Player attack!";
}
if (crit >= 9)
{
wmp3.URL = "sound/cr.wav";
label4.Text = "Player Crit attack!";
}
if (crit >= 6)
if (radioButton6.Checked == true)
{
wmp3.URL = "sound/cr.wav";
timer3.Enabled = false;
}
wmp3.Ctlcontrols.play();
attack(enhp, crit, 1);
timer7.Enabled = true;
///////////////////////////////////////////////////////////////////
// cmbSkill.Items.Add("Player attack!" ;
label4.Visible = true;
radioButton5.Visible = false;
radioButton6.Visible = false;
radioButton7.Visible = false;
radioButton8.Visible = false;
locked = 0;
}
else if (radioButton2.Checked == true)
{
enemyAttackTimer.Enabled = false;
Playerattacttimer.Enabled = false;
label4.Text = "丟出大師球";
this.Refresh();
pokeball();
}
else if (radioButton4.Checked == true)
{
enemyAttackTimer.Enabled = false;
Playerattacttimer.Enabled = false;
if (crit2 > 30)
{
stop();
outside = 1;
wmp3.URL = "sound/out.wav";
wmp3.Ctlcontrols.play();
label4.Text = "逃跑成功!!";
}
else
{
enemyAttackTimer.Enabled = true;
Playerattacttimer.Enabled = true;
wmp3.URL = "sound/out.wav";
wmp3.Ctlcontrols.play();
label4.Text = "逃跑失敗!!";
enyattack();
}
}
}
private void wmp_StatusChange(object sender, EventArgs e)
{
/* if ((int)wmp.playState == 1)//如果播放状态等于停止
{
if (start == 0)
{
enemyAttackTimer.Enabled = true;
Playerattacttimer.Enabled = true;
wmp2.URL = "battle.mp3";
wmp2.Ctlcontrols.play(); //这里写你的处理代码
start = 1;
}
}*/
}
void pokeball()
{
// 初始化画板
Bitmap image = new Bitmap(pictureBox1.ClientSize.Width, pictureBox1.ClientSize.Height);
MP3Player mp3 = new MP3Player();
// 获取背景层
Bitmap bg = (Bitmap)pictureBox1.BackgroundImage;
Bitmap bmplayer2 = new Bitmap("pok/ball.png");
// 初始化画布
Bitmap canvas = new Bitmap(pictureBox1.ClientSize.Width, pictureBox1.ClientSize.Height);
// 初始化图形面板
Graphics g = Graphics.FromImage(image);
Graphics gb = Graphics.FromImage(canvas);
catching = 1;
radioButton1.Enabled = false;
radioButton2.Enabled = false;
radioButton3.Enabled = false;
radioButton4.Enabled = false;
pictureBox2.BackgroundImage = canvas; // 设置为背景层
pictureBox2.CreateGraphics().DrawImage(canvas, 0, 0);
bg = new Bitmap("pok/back.png");
double t;
int xxx = 0;
back.Play("sound/throw.wav");
for (t = -5; t < 2; t = t + 0.2)
{
double x = xx(2.5 * t, 500);
double y = yy(3 * t, 0);
DRAWIMAGEXX(gb, TakeScreenshot(0, xxx, bmplayer2, 17, 17, 17, 17, 1.5), Convert.ToInt32(x), Convert.ToInt32(y), 1, 1);
if (y < 300 && x > 450)
{
tmpx = x + 10;
tmpy = y;
mp3.Play("sound/inside2.wav");
break;
}
if (xxx <= 320)
xxx += 40;
else
xxx = 0;
label3.Text = Convert.ToInt32(x).ToString() + ":" + Convert.ToInt32(y).ToString();
}
DRAWIMAGEXX(gb, TakeScreenshot(0, 400, bmplayer2, 17, 17, 17, 17, 1.5), Convert.ToInt32(tmpx), Convert.ToInt32(tmpy), 1, 1);
for (t = 7; t >= 6; t = t - 0.2)
{
sleeptime = 5;
Thread t1 = new Thread(MyBackgroundTask2);
t1.Start();
t1.Join();
double x = xx(2.5 * t, tmpx);
double y = yy(0.2 * t, tmpy);
if (t == 6)
{
tmpx = x;
tmpy = y;
}
}
DRAWIMAGEXX(gb, TakeScreenshot(0, 400, bmplayer2, 17, 17, 17, 17, 1.5), Convert.ToInt32(tmpx), Convert.ToInt32(tmpy), 1, 1);
EnemyPB1.SendToBack();
mp3.Play("sound/inside.wav");
for (double i = 2; i >= 1; i -= 0.1)
{
sleeptime = 1;
Thread t1 = new Thread(MyBackgroundTask2);
t1.Start();
t1.Join();
DRAWIMAGEXX(gb, TakeScreenshot(0, 400, bmplayer2, 17, 17, 17, 17, 1.5), Convert.ToInt32(tmpx), Convert.ToInt32(tmpy), 0, 0);
DRAWIMAGEXX(gb, TakeScreenshot(0, 0, bmplayer3, 1, 1, 1, 1, i), EnemyPB1.Location.X, EnemyPB1.Location.Y, 1, 1);
if (EnemyPB1.Location.X >= pictureBox2.Location.X + 50)
EnemyPB1.Location = new Point(EnemyPB1.Location.X - 2, EnemyPB1.Location.Y - 1);
else
EnemyPB1.Image = null;
}
DRAWIMAGEXX(gb, TakeScreenshot(0, 0, bmplayer2, 17, 17, 17, 17, 1.5), Convert.ToInt32(tmpx), Convert.ToInt32(tmpy), 1, 1);
back.Play("sound/ballund.wav");
for (t = 0; t < 5; t = t + 0.4)
{
double x = tmpx;
double y = yy(1.5 * t, 0);
if (y >= 200)
{
tmpy = y;
break;
}
DRAWIMAGEXX(gb, TakeScreenshot(0, 0, bmplayer2, 17, 17, 17, 17, 1.5), Convert.ToInt32(tmpx), Convert.ToInt32(tmpy), 1, 1);
tmpy = y;
}
for (t = 5; t >= 0; t = t - 0.2)
{
double x = tmpx;
double y = yy(t, 0);
if (y <= 100)
{
tmpy = 100;
break;
}
DRAWIMAGEXX(gb, TakeScreenshot(0, 0, bmplayer2, 17, 17, 17, 17, 1.5), Convert.ToInt32(tmpx), Convert.ToInt32(tmpy), 1, 1);
tmpy = y;
}
back.Play("sound/ballund.wav");
for (t = 0; t < 5; t = t + 0.4)
{
double x = tmpx;
double y = yy(1.5 * t, tmpy);
if (y >= 200)
{
break;
}
DRAWIMAGEXX(gb, TakeScreenshot(0, 0, bmplayer2, 17, 17, 17, 17, 1.5), Convert.ToInt32(tmpx), Convert.ToInt32(tmpy), 1, 1);
tmpy = y;
}
int pok = 440;
for (int j = 1; j <= 6; j++)
{
if (j % 2 == 0) pok = 440; else pok = 560;
for (int i = 1; i <= 29; i += 2)
{
label3.Text = i.ToString();
if (i == 1)
mp3.Play("sound/ball.wav");
sleeptime = 1;
Thread t1 = new Thread(MyBackgroundTask2);
t1.Start();
t1.Join();
bmplayer2 = new Bitmap("pok/ball.png");
DRAWIMAGEXX(gb, TakeScreenshot(0, pok, bmplayer2, 17, 17, 17, 17, 1.5), Convert.ToInt32(tmpx), Convert.ToInt32(tmpy), 1, 1);
if (i % 9 == 0)
pok += 40;
}
DRAWIMAGEXX(gb, TakeScreenshot(0, 0, bmplayer2, 17, 17, 17, 17, 1.5), Convert.ToInt32(tmpx), Convert.ToInt32(tmpy), 1, 1);
}
mp3.Play("sound/get.mp3");
DRAWIMAGEXX(gb, TakeScreenshot(0, 0, bmplayer2, 17, 17, 17, 17, 1.5), Convert.ToInt32(tmpx), Convert.ToInt32(tmpy), 1, 1);
EnemyPB1.Location = new Point(enytmpx, enytmpy);
label4.Text = "抓到了!!";
wmp2.URL = "sound/win2.mp3";
wmp2.Ctlcontrols.play();
if(pokarr[11]=="-1")
get_pok();
catcho = 1;
stop();
gb.Clear(Color.Transparent);
catching = 0;
radioButton1.Enabled = true;
if (train == 1)
radioButton2.Enabled = false;
else
radioButton2.Enabled = true;
radioButton3.Enabled = true;
radioButton4.Enabled = true;
}
public void DRAWIMAGEXX(Graphics gb, Bitmap image, double x, double y, int refresh, int clear)
{
gb.DrawImage(image, Convert.ToInt32(x), Convert.ToInt32(y)); // 先绘制背景层
if (refresh == 1)
pictureBox2.Refresh();
if (clear == 1)
gb.Clear(Color.Transparent);
GC.Collect();
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
back.Play("sound/menu.wav");
}
void stop()
{
enemyAttackTimer.Enabled = false;
Playerattacttimer.Enabled = false;
}
void start()
{
enemyAttackTimer.Enabled = true;
Playerattacttimer.Enabled = true;
}
private double xx(double t, double basex)
{
double v0 = 30;//水平初速度
return (v0 * t) + basex;
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
back.Play("sound/menu.wav");
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
back.Play("sound/menu.wav");
}
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
if (catcho == 1 || win == 1 || outside == 1 || over == 1)
{
over = 1; this.Close();
}
back.Play("sound/menu.wav");
}
private void timer7_Tick(object sender, EventArgs e)
{
sh1 += 1;
if (EnemyPB1.Visible == true)
EnemyPB1.Visible = false;
else
EnemyPB1.Visible = true;
if (sh1 >= 4)
{
EnemyPB1.Visible = true;
timer7.Enabled = false;
locked = 0;
sh1 = 0;
}
}
private void timer8_Tick(object sender, EventArgs e)
{
sh2 += 1;
if (PartyPB1.Visible == true)
PartyPB1.Visible = false;
else
PartyPB1.Visible = true;
if (sh2 >= 4)
{
PartyPB1.Visible = true;
timer8.Enabled = false;
sh2 = 0;
}
}
private void button3_Click(object sender, EventArgs e)
{
pictureBox5.Size = new Size(pictureBox5.Size.Width + 5, pictureBox5.Size.Height);
}
public void attack(int basic, int sum, int change)
{
plattack = basic * sum;
plattack_now = pictureBox5.Size.Width - plattack;
if (change == 1)
timer9.Enabled = true;
timer9.Enabled = true;
}
public void attack2(int basic, int sum)
{
enattack = basic * sum;
enattack_now = pictureBox7.Size.Width - enattack;
timer10.Enabled = true;
}
void enyattack()
{
Random crandom = new Random(Guid.NewGuid().GetHashCode());
int crit = crandom.Next(1, 10);
if (crit < 2)
{
wmp3.URL = "sound/lit.wav";
label4.Text = "enermy Attack!!";
}
if (crit > 2 && crit < 9)
{
wmp3.URL = "sound/knf.wav";
label4.Text = "enermy Attack!!";
}
if (crit >= 9)
{
label4.Text = "enermy Attack!!";
wmp3.URL = "sound/cr.wav";
}
wmp3.Ctlcontrols.play();
attack2(plhp, crit);
timer8.Enabled = true;
}
private void timer9_Tick(object sender, EventArgs e)
{
radioButton1.Enabled = false;
radioButton2.Enabled = false;
radioButton3.Enabled = false;
radioButton4.Enabled = false;
this.Refresh();
if ((pictureBox5.Size.Width) <= 150 && (pictureBox5.Size.Width) >= 50)
pictureBox5.BackColor = Color.Orange;
else if ((pictureBox5.Size.Width) < 50)
pictureBox5.BackColor = Color.Red;
if ((pictureBox5.Size.Width - 1) != plattack_now)
pictureBox5.Size = new Size(pictureBox5.Size.Width - 1, pictureBox5.Size.Height);
else
{
start();
plattack = 0;
plattack_now = 0;
timer9.Enabled = false;
enyattack();
}
if (pictureBox5.Size.Width <= 0)
{
label4.Text = "Youw Win!!";
win = 1;
wmp2.URL = "sound/win.mp3";
wmp2.Ctlcontrols.play();
timer9.Enabled = false;
wmp5.Ctlcontrols.stop();
timer3.Enabled = false;
timer4.Enabled = false;
timer5.Enabled = false;
timer6.Enabled = false;
radioButton1.Enabled = true;
if (train == 1)
radioButton2.Enabled = false;
else
radioButton2.Enabled = true;
radioButton3.Enabled = true;
radioButton4.Enabled = true;
stop();
}
}
private void timer10_Tick(object sender, EventArgs e)
{
radioButton1.Enabled = false;
radioButton2.Enabled = false;
radioButton3.Enabled = false;
radioButton4.Enabled = false;
this.Refresh();
if ((pictureBox7.Size.Width) > 150)
{
wmp2.Ctlcontrols.play();
wmp5.Ctlcontrols.pause();
pictureBox7.BackColor = Color.MediumSeaGreen;
}
else if ((pictureBox7.Size.Width) <= 150 && (pictureBox7.Size.Width) >= 50)
{
wmp2.Ctlcontrols.play();
wmp5.Ctlcontrols.pause();
pictureBox7.BackColor = Color.Orange;
}
else if ((pictureBox7.Size.Width) < 50)
{
wmp2.Ctlcontrols.pause();
if (wmp5.URL != "sound/lowhp.mp3")
wmp5.URL = "sound/lowhp.mp3";
wmp5.Ctlcontrols.play();
pictureBox7.BackColor = Color.Red;
}
if ((pictureBox7.Size.Width - 1) != enattack_now)
pictureBox7.Size = new Size(pictureBox7.Size.Width - 1, pictureBox7.Size.Height);
else
{
label4.Text = "what to do now?";
radioButton1.Enabled = true;
if (train == 1)
radioButton2.Enabled = false;
else
radioButton2.Enabled = true;
radioButton3.Enabled = true;
radioButton4.Enabled = true;
stop();
start();
enattack = 0;
enattack_now = 0;
timer10.Enabled = false;
radioButton5.Checked =false;
}
if (pictureBox7.Size.Width <= 0)
{
pictureBox1.BringToFront();
pictureBox1.ImageLocation = "pok/gameover.png";
enemyAttackTimer.Enabled = false;
wmp2.Ctlcontrols.stop();
pictureBox1.Visible = true;
wmp.Ctlcontrols.stop();
wmp2.Ctlcontrols.stop();
wmp.URL = "sound/gameover.mid";
wmp.Ctlcontrols.play();
Thread t1 = new Thread(MyBackgroundTask);
t1.Start();
timer10.Enabled = false;
wmp5.Ctlcontrols.stop();
stop();
}
}
private void radioButton5_CheckedChanged(object sender, EventArgs e)
{
back.Play("sound/menu.wav");
locked = 1;
}
private void radioButton6_CheckedChanged(object sender, EventArgs e)
{
back.Play("sound/menu.wav");
locked = 1;
}
private void radioButton7_CheckedChanged(object sender, EventArgs e)
{
back.Play("sound/menu.wav");
locked = 1;
}
private void radioButton8_CheckedChanged(object sender, EventArgs e)
{
back.Play("sound/menu.wav");
locked = 1;
}
private void timer3_Tick(object sender, EventArgs e)
{
Poison--;
pictureBox11.BackColor = Color.Purple;
attack(enhp, 1, 0);
if (Poison <= 0)
{
pictureBox11.BackColor = Color.White;
timer3.Enabled = false;
Poison = 3;
}
}
private void wmp_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if (e.newState == 1)
this.wmp.Ctlcontrols.play();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
private double yy(double t, double basey)
{
double g = 9.8;//重力加速度
return (0.5 * g * t * t) + basey;
}
int pok_length;
string all_pok;
int item;
string[] pokarr = new string[12];
private void check_pok()
{
StreamReader sr = new StreamReader(@"pok.txt");
string a;
//===逐行讀取,直到檔尾===
item = 0;
while (!sr.EndOfStream)
{
a = sr.ReadLine();
string[] strArray = a.Split(',');
for (int i = 0; i < strArray.Length; i++) //透過迴圈將陣列值取出 也可用foreach
{
pokarr[item] = strArray[i].ToString();
item++;
}
pok_length = strArray.Length;
}
sr.Close();
}
private void get_pok()
{
for (int i= 0; i <14; i++)
{
if (pokarr[i] == "-1")
{
item = i;
break;
}
}
pokarr[item] = now_monname;
pokarr[item+1] = "1000";
for (int i = 0; i < 12; i++)
{
all_pok += pokarr[i];
if ((i + 1) % 2 == 0)
{
all_pok += "\r\n";
}
else
all_pok += ",";
}
StreamWriter sw = new StreamWriter(@"pok.txt", false);
//第二個參數設定為true表示不覆蓋原本的內容,把新內容直接添加進去
sw.Write(all_pok);
sw.Flush();
sw.Close();
all_pok = null;
}
}
/*
public static class ModifyProgressBarColor
{
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr w, IntPtr l);
public static void SetState(this ProgressBar pBar, int state)
{
SendMessage(pBar.Handle, 1040, (IntPtr)state, IntPtr.Zero);
}
}*/
}
view raw CombatGUI.cs hosted with ❤ by GitHub
namespace WindowsFormsApplication1
{
partial class CombatGUI
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CombatGUI));
this.enemyAttackTimer = new System.Windows.Forms.Timer(this.components);
this.Playerattacttimer = new System.Windows.Forms.Timer(this.components);
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.progressBar2 = new System.Windows.Forms.ProgressBar();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.wmp = new AxWMPLib.AxWindowsMediaPlayer();
this.wmp2 = new AxWMPLib.AxWindowsMediaPlayer();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.wmp3 = new AxWMPLib.AxWindowsMediaPlayer();
this.wmp4 = new AxWMPLib.AxWindowsMediaPlayer();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.label3 = new System.Windows.Forms.Label();
this.timer3 = new System.Windows.Forms.Timer(this.components);
this.timer4 = new System.Windows.Forms.Timer(this.components);
this.timer5 = new System.Windows.Forms.Timer(this.components);
this.timer6 = new System.Windows.Forms.Timer(this.components);
this.label4 = new System.Windows.Forms.Label();
this.timer7 = new System.Windows.Forms.Timer(this.components);
this.timer8 = new System.Windows.Forms.Timer(this.components);
this.timer9 = new System.Windows.Forms.Timer(this.components);
this.wmp5 = new AxWMPLib.AxWindowsMediaPlayer();
this.timer10 = new System.Windows.Forms.Timer(this.components);
this.radioButton5 = new System.Windows.Forms.RadioButton();
this.radioButton6 = new System.Windows.Forms.RadioButton();
this.radioButton7 = new System.Windows.Forms.RadioButton();
this.radioButton8 = new System.Windows.Forms.RadioButton();
this.pictureBox11 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.PartyPB1 = new System.Windows.Forms.PictureBox();
this.EnemyPB1 = new System.Windows.Forms.PictureBox();
this.pictureBox5 = new System.Windows.Forms.PictureBox();
this.pictureBox6 = new System.Windows.Forms.PictureBox();
this.pictureBox10 = new System.Windows.Forms.PictureBox();
this.pictureBox7 = new System.Windows.Forms.PictureBox();
this.pictureBox8 = new System.Windows.Forms.PictureBox();
this.pictureBox9 = new System.Windows.Forms.PictureBox();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.wmp)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.wmp2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.wmp3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.wmp4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.wmp5)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox11)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PartyPB1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.EnemyPB1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox10)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox8)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox9)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.SuspendLayout();
//
// enemyAttackTimer
//
this.enemyAttackTimer.Tick += new System.EventHandler(this.enemyAttackTimer_Tick_1);
//
// Playerattacttimer
//
this.Playerattacttimer.Tick += new System.EventHandler(this.Playerattacttimer_Tick);
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(119, 57);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(200, 10);
this.progressBar1.TabIndex = 10;
//
// progressBar2
//
this.progressBar2.Location = new System.Drawing.Point(497, 409);
this.progressBar2.Name = "progressBar2";
this.progressBar2.Size = new System.Drawing.Size(198, 10);
this.progressBar2.TabIndex = 11;
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.Color.Red;
this.label1.Location = new System.Drawing.Point(155, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(91, 25);
this.label1.TabIndex = 12;
this.label1.Text = "Enermy";
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.ForeColor = System.Drawing.Color.Black;
this.label2.Location = new System.Drawing.Point(331, 343);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(101, 33);
this.label2.TabIndex = 13;
this.label2.Text = "player";
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// wmp
//
this.wmp.Enabled = true;
this.wmp.Location = new System.Drawing.Point(719, 304);
this.wmp.Name = "wmp";
this.wmp.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wmp.OcxState")));
this.wmp.Size = new System.Drawing.Size(75, 23);
this.wmp.TabIndex = 16;
this.wmp.Visible = false;
this.wmp.StatusChange += new System.EventHandler(this.wmp_StatusChange);
//
// wmp2
//
this.wmp2.Enabled = true;
this.wmp2.Location = new System.Drawing.Point(719, 275);
this.wmp2.Name = "wmp2";
this.wmp2.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wmp2.OcxState")));
this.wmp2.Size = new System.Drawing.Size(75, 23);
this.wmp2.TabIndex = 18;
this.wmp2.Visible = false;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.BackColor = System.Drawing.Color.Transparent;
this.radioButton1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton1.Location = new System.Drawing.Point(515, 504);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(88, 35);
this.radioButton1.TabIndex = 19;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "ATK";
this.radioButton1.UseVisualStyleBackColor = false;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.BackColor = System.Drawing.Color.Transparent;
this.radioButton2.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton2.Location = new System.Drawing.Point(633, 504);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(115, 35);
this.radioButton2.TabIndex = 20;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "PKMO";
this.radioButton2.UseVisualStyleBackColor = false;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.BackColor = System.Drawing.Color.Transparent;
this.radioButton3.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton3.Location = new System.Drawing.Point(515, 570);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(92, 35);
this.radioButton3.TabIndex = 21;
this.radioButton3.TabStop = true;
this.radioButton3.Text = "BAG";
this.radioButton3.UseVisualStyleBackColor = false;
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
//
// radioButton4
//
this.radioButton4.AutoSize = true;
this.radioButton4.BackColor = System.Drawing.Color.Transparent;
this.radioButton4.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton4.Location = new System.Drawing.Point(633, 570);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(95, 35);
this.radioButton4.TabIndex = 22;
this.radioButton4.TabStop = true;
this.radioButton4.Text = "RUN";
this.radioButton4.UseVisualStyleBackColor = false;
this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
//
// wmp3
//
this.wmp3.Enabled = true;
this.wmp3.Location = new System.Drawing.Point(626, 277);
this.wmp3.Name = "wmp3";
this.wmp3.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wmp3.OcxState")));
this.wmp3.Size = new System.Drawing.Size(75, 23);
this.wmp3.TabIndex = 23;
this.wmp3.Visible = false;
//
// wmp4
//
this.wmp4.Enabled = true;
this.wmp4.Location = new System.Drawing.Point(626, 304);
this.wmp4.Name = "wmp4";
this.wmp4.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wmp4.OcxState")));
this.wmp4.Size = new System.Drawing.Size(75, 23);
this.wmp4.TabIndex = 25;
this.wmp4.Visible = false;
//
// timer2
//
this.timer2.Interval = 1000;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(759, 406);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(35, 13);
this.label3.TabIndex = 26;
this.label3.Text = "label3";
//
// timer3
//
this.timer3.Interval = 3000;
this.timer3.Tick += new System.EventHandler(this.timer3_Tick);
//
// timer4
//
this.timer4.Interval = 3000;
//
// timer5
//
this.timer5.Interval = 3000;
//
// timer6
//
this.timer6.Interval = 3000;
//
// label4
//
this.label4.AutoSize = true;
this.label4.BackColor = System.Drawing.SystemColors.Control;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(24, 504);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(0, 31);
this.label4.TabIndex = 33;
//
// timer7
//
this.timer7.Tick += new System.EventHandler(this.timer7_Tick);
//
// timer8
//
this.timer8.Tick += new System.EventHandler(this.timer8_Tick);
//
// timer9
//
this.timer9.Interval = 5;
this.timer9.Tick += new System.EventHandler(this.timer9_Tick);
//
// wmp5
//
this.wmp5.Enabled = true;
this.wmp5.Location = new System.Drawing.Point(626, 333);
this.wmp5.Name = "wmp5";
this.wmp5.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wmp5.OcxState")));
this.wmp5.Size = new System.Drawing.Size(75, 23);
this.wmp5.TabIndex = 37;
this.wmp5.Visible = false;
//
// timer10
//
this.timer10.Interval = 5;
this.timer10.Tick += new System.EventHandler(this.timer10_Tick);
//
// radioButton5
//
this.radioButton5.AutoSize = true;
this.radioButton5.BackColor = System.Drawing.Color.Transparent;
this.radioButton5.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton5.Location = new System.Drawing.Point(49, 515);
this.radioButton5.Name = "radioButton5";
this.radioButton5.Size = new System.Drawing.Size(108, 35);
this.radioButton5.TabIndex = 42;
this.radioButton5.TabStop = true;
this.radioButton5.Text = "Strike";
this.radioButton5.UseVisualStyleBackColor = false;
this.radioButton5.Visible = false;
this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
//
// radioButton6
//
this.radioButton6.AutoSize = true;
this.radioButton6.BackColor = System.Drawing.Color.Transparent;
this.radioButton6.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton6.Location = new System.Drawing.Point(294, 515);
this.radioButton6.Name = "radioButton6";
this.radioButton6.Size = new System.Drawing.Size(121, 35);
this.radioButton6.TabIndex = 43;
this.radioButton6.TabStop = true;
this.radioButton6.Text = "Poison";
this.radioButton6.UseVisualStyleBackColor = false;
this.radioButton6.Visible = false;
this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton6_CheckedChanged);
//
// radioButton7
//
this.radioButton7.AutoSize = true;
this.radioButton7.BackColor = System.Drawing.Color.Transparent;
this.radioButton7.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton7.Location = new System.Drawing.Point(49, 570);
this.radioButton7.Name = "radioButton7";
this.radioButton7.Size = new System.Drawing.Size(127, 35);
this.radioButton7.TabIndex = 44;
this.radioButton7.TabStop = true;
this.radioButton7.Text = "electric";
this.radioButton7.UseVisualStyleBackColor = false;
this.radioButton7.Visible = false;
this.radioButton7.CheckedChanged += new System.EventHandler(this.radioButton7_CheckedChanged);
//
// radioButton8
//
this.radioButton8.AutoSize = true;
this.radioButton8.BackColor = System.Drawing.Color.Transparent;
this.radioButton8.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton8.Location = new System.Drawing.Point(294, 570);
this.radioButton8.Name = "radioButton8";
this.radioButton8.Size = new System.Drawing.Size(163, 35);
this.radioButton8.TabIndex = 45;
this.radioButton8.TabStop = true;
this.radioButton8.Text = "Hypnotize";
this.radioButton8.UseVisualStyleBackColor = false;
this.radioButton8.Visible = false;
this.radioButton8.CheckedChanged += new System.EventHandler(this.radioButton8_CheckedChanged);
//
// pictureBox11
//
this.pictureBox11.BackColor = System.Drawing.Color.White;
this.pictureBox11.Location = new System.Drawing.Point(294, 9);
this.pictureBox11.Name = "pictureBox11";
this.pictureBox11.Size = new System.Drawing.Size(25, 24);
this.pictureBox11.TabIndex = 46;
this.pictureBox11.TabStop = false;
//
// pictureBox3
//
this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
this.pictureBox3.Location = new System.Drawing.Point(2, 485);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(489, 159);
this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox3.TabIndex = 31;
this.pictureBox3.TabStop = false;
//
// PartyPB1
//
this.PartyPB1.BackColor = System.Drawing.Color.Transparent;
this.PartyPB1.Location = new System.Drawing.Point(68, 328);
this.PartyPB1.Name = "PartyPB1";
this.PartyPB1.Size = new System.Drawing.Size(178, 249);
this.PartyPB1.TabIndex = 4;
this.PartyPB1.TabStop = false;
//
// EnemyPB1
//
this.EnemyPB1.BackColor = System.Drawing.Color.Transparent;
this.EnemyPB1.Location = new System.Drawing.Point(578, 43);
this.EnemyPB1.Name = "EnemyPB1";
this.EnemyPB1.Size = new System.Drawing.Size(178, 249);
this.EnemyPB1.TabIndex = 5;
this.EnemyPB1.TabStop = false;
//
// pictureBox5
//
this.pictureBox5.BackColor = System.Drawing.Color.MediumSeaGreen;
this.pictureBox5.Location = new System.Drawing.Point(130, 41);
this.pictureBox5.Name = "pictureBox5";
this.pictureBox5.Size = new System.Drawing.Size(200, 10);
this.pictureBox5.TabIndex = 34;
this.pictureBox5.TabStop = false;
//
// pictureBox6
//
this.pictureBox6.BackColor = System.Drawing.SystemColors.ButtonFace;
this.pictureBox6.Location = new System.Drawing.Point(130, 41);
this.pictureBox6.Name = "pictureBox6";
this.pictureBox6.Size = new System.Drawing.Size(200, 10);
this.pictureBox6.TabIndex = 35;
this.pictureBox6.TabStop = false;
//
// pictureBox10
//
this.pictureBox10.Image = global::pokemon.Properties.Resources.battleen;
this.pictureBox10.Location = new System.Drawing.Point(-11, 2);
this.pictureBox10.Name = "pictureBox10";
this.pictureBox10.Size = new System.Drawing.Size(361, 93);
this.pictureBox10.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox10.TabIndex = 41;
this.pictureBox10.TabStop = false;
//
// pictureBox7
//
this.pictureBox7.BackColor = System.Drawing.Color.MediumSeaGreen;
this.pictureBox7.Location = new System.Drawing.Point(515, 389);
this.pictureBox7.Name = "pictureBox7";
this.pictureBox7.Size = new System.Drawing.Size(200, 10);
this.pictureBox7.TabIndex = 38;
this.pictureBox7.TabStop = false;
//
// pictureBox8
//
this.pictureBox8.BackColor = System.Drawing.SystemColors.ButtonFace;
this.pictureBox8.Location = new System.Drawing.Point(515, 389);
this.pictureBox8.Name = "pictureBox8";
this.pictureBox8.Size = new System.Drawing.Size(200, 10);
this.pictureBox8.TabIndex = 39;
this.pictureBox8.TabStop = false;
//
// pictureBox9
//
this.pictureBox9.Image = global::pokemon.Properties.Resources.battleme;
this.pictureBox9.Location = new System.Drawing.Point(272, 333);
this.pictureBox9.Name = "pictureBox9";
this.pictureBox9.Size = new System.Drawing.Size(487, 146);
this.pictureBox9.TabIndex = 40;
this.pictureBox9.TabStop = false;
//
// pictureBox4
//
this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
this.pictureBox4.Location = new System.Drawing.Point(497, 485);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(262, 159);
this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox4.TabIndex = 32;
this.pictureBox4.TabStop = false;
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.White;
this.pictureBox1.ImageLocation = "gameover.png";
this.pictureBox1.Location = new System.Drawing.Point(-1, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(778, 655);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 17;
this.pictureBox1.TabStop = false;
this.pictureBox1.Visible = false;
//
// pictureBox2
//
this.pictureBox2.BackColor = System.Drawing.Color.Transparent;
this.pictureBox2.Location = new System.Drawing.Point(0, 0);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(777, 327);
this.pictureBox2.TabIndex = 24;
this.pictureBox2.TabStop = false;
//
// button1
//
this.button1.Location = new System.Drawing.Point(673, 545);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 47;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// CombatGUI
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ButtonFace;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize = new System.Drawing.Size(776, 653);
this.Controls.Add(this.pictureBox11);
this.Controls.Add(this.radioButton8);
this.Controls.Add(this.radioButton7);
this.Controls.Add(this.radioButton6);
this.Controls.Add(this.radioButton5);
this.Controls.Add(this.label4);
this.Controls.Add(this.pictureBox3);
this.Controls.Add(this.PartyPB1);
this.Controls.Add(this.EnemyPB1);
this.Controls.Add(this.label1);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.pictureBox5);
this.Controls.Add(this.pictureBox6);
this.Controls.Add(this.pictureBox10);
this.Controls.Add(this.pictureBox7);
this.Controls.Add(this.pictureBox8);
this.Controls.Add(this.progressBar2);
this.Controls.Add(this.label2);
this.Controls.Add(this.pictureBox9);
this.Controls.Add(this.wmp5);
this.Controls.Add(this.radioButton3);
this.Controls.Add(this.radioButton4);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.pictureBox4);
this.Controls.Add(this.label3);
this.Controls.Add(this.wmp4);
this.Controls.Add(this.wmp3);
this.Controls.Add(this.wmp2);
this.Controls.Add(this.wmp);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.button1);
this.DoubleBuffered = true;
this.KeyPreview = true;
this.Name = "CombatGUI";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "CombatGUI";
this.Load += new System.EventHandler(this.CombatGUI_Load);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CombatGUI_KeyDown);
((System.ComponentModel.ISupportInitialize)(this.wmp)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.wmp2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.wmp3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.wmp4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.wmp5)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox11)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PartyPB1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.EnemyPB1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox10)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox8)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox9)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Timer enemyAttackTimer;
private System.Windows.Forms.Timer Playerattacttimer;
private System.Windows.Forms.PictureBox PartyPB1;
private System.Windows.Forms.PictureBox EnemyPB1;
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.ProgressBar progressBar2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Timer timer1;
private AxWMPLib.AxWindowsMediaPlayer wmp;
private System.Windows.Forms.PictureBox pictureBox1;
private AxWMPLib.AxWindowsMediaPlayer wmp2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton3;
private System.Windows.Forms.RadioButton radioButton4;
private AxWMPLib.AxWindowsMediaPlayer wmp3;
private System.Windows.Forms.PictureBox pictureBox2;
private AxWMPLib.AxWindowsMediaPlayer wmp4;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Timer timer3;
private System.Windows.Forms.Timer timer4;
private System.Windows.Forms.Timer timer5;
private System.Windows.Forms.Timer timer6;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBox4;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Timer timer7;
private System.Windows.Forms.Timer timer8;
private System.Windows.Forms.PictureBox pictureBox5;
private System.Windows.Forms.PictureBox pictureBox6;
private System.Windows.Forms.Timer timer9;
private AxWMPLib.AxWindowsMediaPlayer wmp5;
private System.Windows.Forms.PictureBox pictureBox7;
private System.Windows.Forms.PictureBox pictureBox8;
private System.Windows.Forms.Timer timer10;
private System.Windows.Forms.PictureBox pictureBox9;
private System.Windows.Forms.PictureBox pictureBox10;
private System.Windows.Forms.RadioButton radioButton5;
private System.Windows.Forms.RadioButton radioButton6;
private System.Windows.Forms.RadioButton radioButton7;
private System.Windows.Forms.RadioButton radioButton8;
private System.Windows.Forms.PictureBox pictureBox11;
private System.Windows.Forms.Button button1;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Gma.UserActivityMonitor;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int start = 0;
int start2 = 0;
int item = 0;
int env2 = 0;
int env = 0;
int enving = 0;
int map1girl = 0;
int map2boy = 0;
int min = 0;
int menu;
int menu2x;
int menu2y;
int talking = 0;
string[] itemarr;
public string[] pokarr;
KeyEventArgs keyboardtmp;
bool IsADown = false;
[DllImport("user32.dll")]
private static extern bool SetWindowPos(int hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
[DllImport("user32.dll")]
public static extern int GetSystemMetrics(int screensize);
public const int SM_CXSCREEN = 0;
public const int SM_CYSCREEN = 1;
private static IntPtr HWND_TOP = IntPtr.Zero;
private const int SWP_SHOWWINDOW = 64;
static Label[] labx = new Label[15];
public Bitmap TakeScreenshot(int x, int y, Bitmap bmpx, int cutx1, int cutx2, int cuty1, int cuty2)
{
Bitmap destBitmap = new Bitmap(bmpx.Width, bmpx.Height);
// destBitmap 為你的目的圖檔,長、寬為原圖1/3
Rectangle destRect = new Rectangle(0, 0, destBitmap.Width / cutx1, destBitmap.Height / cuty1); // 你的輸出範圍
Rectangle srcRect = new Rectangle(x, y, bmpx.Width / cutx1, bmpx.Height / cuty2); // 你的原圖剪裁區域
Graphics.FromImage(destBitmap).DrawImage(bmpx, destRect, srcRect, GraphicsUnit.Pixel);
return destBitmap;
}
public Class1 game;
public Form1()
{
InitializeComponent();
}
public void AlphaBlend(Bitmap source, byte alpha, Color backColor)
{
for (int x = 0; x < source.Width; x++)
{
for (int y = 0; y < source.Height; y++)
{
Color sc = source.GetPixel(x, y);
byte R = (byte)(sc.R * alpha / 255 + backColor.R * (255 - alpha) / 255);
byte G = (byte)(sc.G * alpha / 255 + backColor.G * (255 - alpha) / 255);
byte B = (byte)(sc.B * alpha / 255 + backColor.B * (255 - alpha) / 255);
byte A = (byte)(sc.A * alpha / 255 + backColor.A * (255 - alpha) / 255);
source.SetPixel(x, y, Color.FromArgb(A, R, G, B));
}
}
}
Bitmap rainDrops;
Timer timer = new Timer();
byte xl = 255;
private void Form1_Load(object sender, EventArgs e)
{
// timer.Interval = 1000;
// timer.Enabled = true;
// timer.Tick += delegate { Invalidate(); };
labx[0] = item0;
labx[1] = item1;
labx[2] = item2;
labx[3] = item3;
labx[4] = item4;
labx[5] = item5;
labx[6] = item6;
labx[7] = item7;
labx[8] = item8;
labx[9] = item9;
labx[10] = item10;
labx[11] = item11;
labx[12] = item12;
itemarr = new string[12];
pokarr = new string[20];
timer2.Enabled = true;
// this.WindowState = FormWindowState.Normal;
// this.FormBorderStyle = FormBorderStyle.None;
// SetWindowPos((int)this.Handle, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
// this.ControlBox = true;
timer2.Enabled = true;
}
private int checkface()
{
if (game.msy < game.ply)
return 1;
else if (game.msy > game.ply)
return 2;
else if (game.msx < game.plx)
return 3;
else if (game.msx > game.plx)
return 4;
else { return 0; }
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
keyboardtmp = e;
if (start == 0 && start2 == 0 && e.KeyCode == Keys.Z)
{
timer5.Enabled = true; back.URL = ("sound/menu.wav");
back.Ctlcontrols.play();
}
if (start == 1)
{
if (enving == 0)
{
game.handlekeypress(e);
}
// if(e.KeyCode==Keys.Z)
// {
if (e.KeyCode == Keys.X && talking == 0)
{
label5.Text = "MAP:" + game.now_map;
if (pictureBox3.Visible == true)
{
enving = 0;
pictureBox3.Visible = false;
pictureBox4.Visible = false;
pictureBox6.Visible = false;
pictureBox7.Visible = false;
pictureBox8.Visible = false;
pictureBox9.Visible = false;
pictureBox10.Visible = false;
label7.Visible = false;
label8.Visible = false;
label10.Visible = false;
label11.Visible = false;
label12.Visible = false;
itemx.Visible = false;
label3.Visible = false;
label4.Visible = false;
label5.Visible = false;
pictureBox5.Visible = false;
for (int i = 0; i < 13; i++)
labx[i].Visible = false;
menu = 0;
}
else
{
menu2y = pictureBox6.Location.Y;
pictureBox4.Location = new Point(517, 43);
enving = 1;
pictureBox3.Visible = true;
pictureBox4.Visible = true;
label3.Visible = true;
label4.Visible = true;
label5.Visible = true;
}
}
if (e.KeyCode == Keys.Down && pictureBox3.Visible == true)
{
if (menu == 2 && menu2y + 116 <= pictureBox10.Location.Y)
menu2y += 116;
if (menu == 0 && pictureBox4.Location.Y + 56 <= label4.Location.Y + 30)
pictureBox4.Location = new Point(pictureBox4.Location.X, pictureBox4.Location.Y + 56);
if (menu == 1 && pictureBox4.Location.Y + 93 <= labx[9].Location.Y + 30)
pictureBox4.Location = new Point(pictureBox4.Location.X, pictureBox4.Location.Y + 93);
for (int i = 0; i < 11; i++)
{
if (labx[i].Location.X == pictureBox4.Location.X + 20 && labx[i].Location.Y == pictureBox4.Location.Y - 5)
{
min = i;
check_item();
}
}
}
if (e.KeyCode == Keys.Up && pictureBox3.Visible == true)
{
if (menu == 2 && menu2y - 116 >= pictureBox6.Location.Y)
menu2y -= 116;
if (menu == 0 && pictureBox4.Location.Y - 56 >= label3.Location.Y - 30)
pictureBox4.Location = new Point(pictureBox4.Location.X, pictureBox4.Location.Y - 56);
if (menu == 1 && pictureBox4.Location.Y - 93 >= labx[0].Location.Y - 30)
pictureBox4.Location = new Point(pictureBox4.Location.X, pictureBox4.Location.Y - 93);
for (int i = 0; i < 11; i++)
{
if (labx[i].Location.X == pictureBox4.Location.X + 20 && labx[i].Location.Y == pictureBox4.Location.Y - 5)
{
min = i;
check_item();
}
}
}
if (e.KeyCode == Keys.Left && itemx.Visible == true)
{
if (menu == 1 && pictureBox4.Location.X - 141 >= labx[0].Location.X - 30)
pictureBox4.Location = new Point(pictureBox4.Location.X - 141, pictureBox4.Location.Y);
for (int i = 0; i < 11; i++)
{
if (labx[i].Location.X == pictureBox4.Location.X + 20 && labx[i].Location.Y == pictureBox4.Location.Y - 5)
{
min = i;
check_item();
}
}
}
if (e.KeyCode == Keys.Right && itemx.Visible == true)
{
if (menu == 1 && pictureBox4.Location.X + 141 <= labx[2].Location.X + 30)
pictureBox4.Location = new Point(pictureBox4.Location.X + 141, pictureBox4.Location.Y);
for (int i = 0; i < 11; i++)
{
if (labx[i].Location.X == pictureBox4.Location.X + 20 && labx[i].Location.Y == pictureBox4.Location.Y - 5)
{
min = i;
check_item();
}
}
}
if (e.KeyCode == Keys.Z && pictureBox3.Visible == true && pictureBox4.Location.Y > label3.Location.Y && label3.Location.Y + label3.Size.Height > pictureBox4.Location.Y && menu == 0)
{
talking = 0;
check_item();
menu = 1;
itemx.Visible = true;
for (int i = 0; i < 13; i++)
labx[i].Visible = true;
pictureBox4.Location = new Point(labx[0].Location.X - 20, labx[0].Location.Y + 5);
}
if (e.KeyCode == Keys.Z && pictureBox3.Visible == true && pictureBox4.Location.Y > label3.Location.Y && label4.Location.Y + label4.Size.Height > pictureBox4.Location.Y && menu == 0)
{
check_pok();
menu2y = pictureBox6.Location.Y + Convert.ToInt32(pokarr[0]) * 116;
talking = 0;
menu = 2;
pictureBox5.Visible = true;
pictureBox6.Visible = true;
pictureBox7.Visible = true;
pictureBox8.Visible = true;
pictureBox9.Visible = true;
pictureBox10.Visible = true;
label7.Visible = true;
label8.Visible = true;
label10.Visible = true;
label11.Visible = true;
label12.Visible = true;
}
if (e.KeyCode == Keys.Z && pictureBox3.Visible == false)
{
if (game.now_map == "Test2.txt" && game.max_monster[0] == 1)
{
talking = 1;
game.talkface(checkface(), 0);
talk(map2boy);
map2boy++;
if (map2boy == 3 && env2 == 0)
{
label9.Text = "統神哥哥:再來阿";
talk(map2boy);
if (game.max_monster[0] == 1)
{
back3.URL = ("再來阿.mp3");
back3.Ctlcontrols.play();
wmp.Ctlcontrols.stop();
game.shock();
game.View(true);
game.ms1();
env2 = 1;
map2boy = 0;
talk(map2boy);
}
}
else if (map2boy == 1 && env2 == 0)
{
label9.Text = "統神哥哥:想幹架嗎??";
talk(map2boy);
map2boy++;
}
else if (map2boy == 3 && env2 == 1)
{
label9.Text = "統神哥哥:外掛狗";
talk(map2boy);
map2boy++;
}
else if (map2boy == 1 && env2 == 1)
{
label9.Text = "統神哥哥:笑笑不多說";
talk(map2boy);
map2boy++;
}
else { map2boy = 0; }
}
/////////////////////////////////////////////////
if (game.now_map == "Test2.txt" && game.max_monster[1] == 1)
{
talking = 1;
game.talkface(checkface(), 1);
talk(map1girl);
map1girl++;
if (map1girl == 5)
{
label9.Text = "你失去了哈密瓜";
talk(map1girl);
map1girl++;
delate_item(1);
}
else if (map1girl == 3)
{
label9.Text = "統表:你他媽有被揍過?無差別偷你哈密瓜";
talk(map1girl);
map1girl++;
}
else if (map1girl == 1)
{
label9.Text = "統表:我哥哥在隔壁別來煩我,滾";
talk(map1girl);
map1girl++;
}
else { map1girl = 0; }
}
/////////////////////////////////////////////////
if (game.now_map == "Test.txt" && game.max_monster[1] == 1)
{
talking = 1;
game.talkface(checkface(), 1);
talk(map1girl);
map1girl++;
if (map1girl == 7 && env == 0)
{
get_item(1);
back2.URL = ("item.mp3");
back2.Ctlcontrols.play();
label9.Text = "獲得哈密瓜.";
talk(map1girl);
map1girl++;
env = 1;
}
else if (map1girl == 5 && env == 0)
{
label9.Text = "小女孩:這是我撿到的一顆東西.";
talk(map1girl);
map1girl++;
}
else if (map1girl == 3)
{
label9.Text = "小女孩:嚇得我,趕快跑回家.";
talk(map1girl);
map1girl++;
}
else if (map1girl == 1)
{
label9.Text = "小女孩:我上次在後山看到一到閃光";
talk(map1girl);
map1girl++;
}
else { map1girl = 0; }
}
/////////////////////////////////////////////////
if (game.now_map == "Test.txt" && game.max_monster[0] == 1)
{
talking = 1;
game.talkface(checkface(), 0);
talk(map2boy);
map2boy++;
if (map2boy == 3)
{
label9.Text = "統神哥哥:你也想去試試看?";
talk(map2boy);
map2boy++;
}
else if (map2boy == 1)
{
label9.Text = "統神哥哥:我弟弟在野區找人單挑";
talk(map2boy);
map2boy++;
}
else { map2boy = 0; }
}
}
}
}
private void check_item()
{
StreamReader sr = new StreamReader(@"item.txt");
string a;
//===逐行讀取,直到檔尾===
item = 0;
while (!sr.EndOfStream)
{
a = sr.ReadLine();
string[] strArray = a.Split(',');
for (int i = 0; i < strArray.Length; i++) //透過迴圈將陣列值取出 也可用foreach
{
if (strArray[i].ToString() == "1")
{
labx[item].Text = "哈密瓜"; itemarr[item] = strArray[i].ToString();
}
else { labx[item].Text = strArray[i].ToString(); itemarr[item] = strArray[i].ToString(); }
item++;
}
}
if (min >= 0)
if (itemarr[min] == "1")
labx[12].Text = "有一點哈味不過還能吃.";
else
labx[12].Text = labx[min].Text;
sr.Close();
}
int zero;
string all_item;
private void delate_item(int item)
{
for (int i = 0; i < 12; i++)
{
all_item += itemarr[i];
if ((i + 1) % 3 == 0)
{
all_item += "\r\n";
}
else
all_item += ",";
}
all_item = all_item.Replace(item.ToString(), "-");
StreamWriter sw = new StreamWriter(@"item.txt", false);
//第二個參數設定為true表示不覆蓋原本的內容,把新內容直接添加進去
sw.Write(all_item);
sw.Flush();
sw.Close();
all_item = null;
}
private void get_item(int item)
{
for (int i = 0; i < 12; i++)
{
if (itemarr[i] == "-")
{ zero = i; break; }
}
if (item == 1)
itemarr[zero] = "1";
for (int i = 0; i < 12; i++)
{
all_item += itemarr[i];
if ((i + 1) % 3 == 0)
{
all_item += "\r\n";
}
else
all_item += ",";
}
StreamWriter sw = new StreamWriter(@"item.txt", false);
//第二個參數設定為true表示不覆蓋原本的內容,把新內容直接添加進去
sw.Write(all_item);
sw.Flush();
sw.Close();
all_item = null;
}
int pok_length;
string all_pok;
private void check_pok()
{
StreamReader sr = new StreamReader(@"pok.txt");
string a;
//===逐行讀取,直到檔尾===
item = 0;
while (!sr.EndOfStream)
{
a = sr.ReadLine();
string[] strArray = a.Split(',');
for (int i = 0; i < strArray.Length; i++) //透過迴圈將陣列值取出 也可用foreach
{
pokarr[item] = strArray[i].ToString();
item++;
}
pok_length = strArray.Length;
}
sr.Close();
}
private void set_pok()
{
for (int i = 0; i < 12; i++)
{
all_pok += pokarr[i];
if ((i + 1) % 2 == 0)
{
all_pok += "\r\n";
}
else
all_pok += ",";
}
StreamWriter sw = new StreamWriter(@"pok.txt", false);
//第二個參數設定為true表示不覆蓋原本的內容,把新內容直接添加進去
sw.Write(all_pok);
sw.Flush();
sw.Close();
all_pok = null;
}
private void talk(int tmp)
{
if (tmp == 0 || tmp % 2 == 0)
{
pictureBox2.Visible = false;
label9.Visible = false;
enving = 0;
talking = 0;
}
else if (tmp % 2 == 1)
{
pictureBox2.Visible = true;
label9.Visible = true;
enving = 1;
talking = 1;
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
Bitmap srcBitmap = new Bitmap("pok/" + "player2.png");// bitmap 為你的原圖
Bitmap destBitmap = new Bitmap(srcBitmap.Width, srcBitmap.Height);
// destBitmap 為你的目的圖檔,長、寬為原圖1/3
Rectangle destRect = new Rectangle(0, 0, destBitmap.Width / 3, destBitmap.Height / 4); // 你的輸出範圍
Rectangle srcRect = new Rectangle(43, 0, srcBitmap.Width / 3, srcBitmap.Height / 4); // 你的原圖剪裁區域
Graphics.FromImage(destBitmap).DrawImage(srcBitmap, destRect
, srcRect, GraphicsUnit.Pixel);
pictureBox1.Image = destBitmap;
}
private void timer2_Tick(object sender, EventArgs e)
{
if (start == 1)
{
if (game.fight == 1)
{
wmp.Ctlcontrols.pause();
if (game.atack.over2() == 1)
{
game.View(false);
wmp.Ctlcontrols.play();
game.fight = 0;
}
}
if (game.changemaptest == 1)
{
if (game.now_map == "Test.txt")
{
wmp.URL = "sound/theme.mp3";
wmp.Ctlcontrols.play();
timer5.Enabled = true;
game.changemaptest = 0;
}
if (game.now_map == "Test2.txt")
{
wmp.URL = "sound/101.mp3";
wmp.Ctlcontrols.play();
timer5.Enabled = true;
game.changemaptest = 0;
}
if (game.now_map == "Test3.txt")
{
wmp.URL = "sound/well.mp3";
wmp.Ctlcontrols.play();
timer5.Enabled = true;
game.changemaptest = 0;
}
}
label2.Text = game.INL.ToString() + "\r" + game.plx.ToString() + ":" + game.ply.ToString() + "\r" + game.msx + ":" + game.msy + "\n" + game.face.ToString() + "\n" + game.pb1x.ToString();
}
}
private void timer3_Tick(object sender, EventArgs e)
{
if (start == 1)
if (game.now_map == "Test.txt" && enving == 0)
{
if (game.times < 6)
{
if (game.npcmove2(3, 0, 1) == 1)
game.times++;
}
if (game.times >= 6 && game.times < 12)
{
if (game.npcmove(1, 0, 1) == 1)
game.times++;
}
if (game.times >= 12 && game.times < 18)
{
if (game.npcmove2(4, 0, 1) == 1)
game.times++;
}
if (game.times >= 18 && game.times < 24)
{
if (game.npcmove(2, 0, 1) == 1)
game.times++;
}
if (game.times >= 24)
{ game.times = 0; }
}
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
try
{
if (game.loding == 1)
{
ProcessMutilKey(keyboardtmp.KeyCode, true);
}
}
catch
{ }
}
private void ProcessMutilKey(Keys MutilKey, bool DownOrUp)
{
if (talking == 0)
{
// 當觸發 A, Ctrl, Alt 鍵時,若為 KeyDown 則把該所屬的旗標設為 true,
// 反之,若為 KeyUp 時則把該所屬的旗標設為 false
if (MutilKey == Keys.Up)
IsADown = DownOrUp;
if (MutilKey == Keys.Down)
IsADown = DownOrUp;
if (MutilKey == Keys.Right)
IsADown = DownOrUp;
if (MutilKey == Keys.Left)
IsADown = DownOrUp;
if (IsADown == true)
{
IsADown = false;
game.handlekeypress2(keyboardtmp);
}
}
}
private void pictureBox2_VisibleChanged(object sender, EventArgs e)
{
back.URL = ("sound/menu.wav");
back.Ctlcontrols.play();
}
private void pictureBox3_VisibleChanged(object sender, EventArgs e)
{
back.URL = ("sound/menu2.wav");
back.Ctlcontrols.play();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
back.URL = ("sound/menu.wav");
back.Ctlcontrols.play();
}
private void pictureBox4_Move(object sender, EventArgs e)
{
back.URL = ("sound/menu.wav");
back.Ctlcontrols.play();
}
private void pictureBox5_VisibleChanged(object sender, EventArgs e)
{
back.URL = ("sound/menu.wav");
back.Ctlcontrols.play();
}
private void back2_StatusChange(object sender, EventArgs e)
{
if ((int)back2.playState == 1)//如果播放状态等于停止
{
wmp.Ctlcontrols.play();
//这里写你的处理代码
}
if (back2.playState == WMPLib.WMPPlayState.wmppsPlaying)//如果播放状态等于停止
{
wmp.Ctlcontrols.stop();
//这里写你的处理代码
}
}
private void wmp_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if (e.newState == 1)
this.wmp.Ctlcontrols.play();
}
private static Bitmap Process(Bitmap originImage, int oriwidth, int oriheight, int width, int height)
{
Bitmap resizedbitmap = new Bitmap(width, height);
Graphics g = Graphics.FromImage(resizedbitmap);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.Clear(Color.Transparent);
g.DrawImage(originImage, new Rectangle(0, 0, width, height), new Rectangle(0, 0, oriwidth, oriheight), GraphicsUnit.Pixel);
return resizedbitmap;
}
public static Bitmap Resize(Bitmap originImage, Double times)
{
int width = Convert.ToInt32(originImage.Width * times);
int height = Convert.ToInt32(originImage.Height * times);
return Process(originImage, originImage.Width, originImage.Height, width, height);
}
public Bitmap TakeScreenshot(int y, int x, Bitmap bmpx, int cutx1, int cutx2, int cuty1, int cuty2, double multiple)
{
Bitmap destBitmap = new Bitmap(bmpx.Width, bmpx.Height);
Rectangle destRect = new Rectangle(0, 0, destBitmap.Width / cutx1, destBitmap.Height / cuty1); // 你的輸出範圍
Rectangle srcRect = new Rectangle(y, x, bmpx.Width / cutx1, bmpx.Height / cuty2); // 你的原圖剪裁區域
Graphics.FromImage(destBitmap).DrawImage(bmpx, destRect, srcRect, GraphicsUnit.Pixel);
return Resize(destBitmap, multiple);
}
private void timer5_Tick(object sender, EventArgs e)
{
if (start2 >= 5 && start == 0)
{
timer5.Dispose();
start2 = 0;
start = 1;
game = new Class1(this);
label6.Dispose();
}
if (start2 % 2 == 0 && start == 0)
label6.ForeColor = Color.White;
else if (start2 % 2 == 1)
label6.ForeColor = Color.Black;
start2 += 1;
}
private void pictureBox5_VisibleChanged_1(object sender, EventArgs e)
{
back.URL = ("sound/menu2.wav");
back.Ctlcontrols.play();
}
Bitmap bmp2;
private void pictureBox6_Paint(object sender, PaintEventArgs e)
{
check_pok(); if (pokarr[2] != "-1")
{
bmp2 = new Bitmap("pok/" + pokarr[2] + ".png");
label7.Text = pokarr[3];
e.Graphics.DrawImage(TakeScreenshot(0, 0, bmp2, 1, 1, 1, 1, 0.7), 40, 0);
}
PictureBox pb = (PictureBox)sender;
if (menu2y == pb.Location.Y)
{
pokarr[0] = "0";
set_pok();
e.Graphics.DrawRectangle(new Pen(Color.Red, 15), 0, 0, pb.Width, pb.Height);
bmp2 = new Bitmap("pok/" + pokarr[2] + ".png");
pictureBox5.Refresh();
}
}
private void pictureBox7_Paint(object sender, PaintEventArgs e)
{
check_pok(); if (pokarr[4] != "-1")
{
bmp2 = new Bitmap("pok/" + pokarr[4] + ".png");
label8.Text = pokarr[5];
e.Graphics.DrawImage(TakeScreenshot(0, 0, bmp2, 1, 1, 1, 1, 0.7), 40, 0);
}
back.URL = ("sound/menu.wav");
back.Ctlcontrols.play();
PictureBox pb = (PictureBox)sender;
if (menu2y == pb.Location.Y)
{
pokarr[0] = "1";
set_pok();
e.Graphics.DrawRectangle(new Pen(Color.Red, 15), 0, 0, pb.Width, pb.Height);
bmp2 = new Bitmap("pok/" + pokarr[4] + ".png");
pictureBox5.Refresh();
}
}
private void pictureBox8_Paint(object sender, PaintEventArgs e)
{
check_pok(); if (pokarr[6] != "-1")
{
bmp2 = new Bitmap("pok/" + pokarr[6] + ".png");
label10.Text = pokarr[7];
e.Graphics.DrawImage(TakeScreenshot(0, 0, bmp2, 1, 1, 1, 1, 0.7), 40, 0);
}
back.URL = ("sound/menu.wav");
back.Ctlcontrols.play();
PictureBox pb = (PictureBox)sender;
if (menu2y == pb.Location.Y)
{
pokarr[0] = "2";
set_pok();
e.Graphics.DrawRectangle(new Pen(Color.Red, 15), 0, 0, pb.Width, pb.Height);
bmp2 = new Bitmap("pok/" + pokarr[6] + ".png");
pictureBox5.Refresh();
}
}
private void pictureBox9_Paint(object sender, PaintEventArgs e)
{
check_pok(); if (pokarr[8] != "-1")
{
bmp2 = new Bitmap("pok/" + pokarr[8] + ".png");
label11.Text = pokarr[9];
e.Graphics.DrawImage(TakeScreenshot(0, 0, bmp2, 1, 1, 1, 1, 0.7), 40, 0);
}
back.URL = ("sound/menu.wav");
back.Ctlcontrols.play();
PictureBox pb = (PictureBox)sender;
if (menu2y == pb.Location.Y)
{
pokarr[0] = "3";
set_pok();
e.Graphics.DrawRectangle(new Pen(Color.Red, 15), 0, 0, pb.Width, pb.Height);
bmp2 = new Bitmap("pok/" + pokarr[8] + ".png");
pictureBox5.Refresh();
}
}
private void pictureBox10_Paint(object sender, PaintEventArgs e)
{
check_pok(); if (pokarr[10] != "-1")
{
bmp2 = new Bitmap("pok/" + pokarr[10] + ".png");
label12.Text = pokarr[11];
e.Graphics.DrawImage(TakeScreenshot(0, 0, bmp2, 1, 1, 1, 1, 0.7), 40, 0);
}
back.URL = ("sound/menu.wav");
back.Ctlcontrols.play();
PictureBox pb = (PictureBox)sender;
if (menu2y == pb.Location.Y)
{
pokarr[0] = "4";
set_pok();
e.Graphics.DrawRectangle(new Pen(Color.Red, 15), 0, 0, pb.Width, pb.Height);
bmp2 = new Bitmap("pok/" + pokarr[10] + ".png");
pictureBox5.Refresh();
}
}
private void timer1_Tick(object sender, EventArgs e)
{
}
private void timer4_Tick(object sender, EventArgs e)
{
}
private void pictureBox5_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(TakeScreenshot(0, 0, bmp2, 1, 1, 1, 1, 2), 20, 0);
}
}
}
view raw Form1.cs hosted with ❤ by GitHub
namespace WindowsFormsApplication1
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.label1 = new System.Windows.Forms.Label();
this.wmp = new AxWMPLib.AxWindowsMediaPlayer();
this.label2 = new System.Windows.Forms.Label();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.timer3 = new System.Windows.Forms.Timer(this.components);
this.label9 = new System.Windows.Forms.Label();
this.back = new AxWMPLib.AxWindowsMediaPlayer();
this.back2 = new AxWMPLib.AxWindowsMediaPlayer();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.item0 = new System.Windows.Forms.Label();
this.item1 = new System.Windows.Forms.Label();
this.item2 = new System.Windows.Forms.Label();
this.item5 = new System.Windows.Forms.Label();
this.item4 = new System.Windows.Forms.Label();
this.item3 = new System.Windows.Forms.Label();
this.item8 = new System.Windows.Forms.Label();
this.item7 = new System.Windows.Forms.Label();
this.item6 = new System.Windows.Forms.Label();
this.item11 = new System.Windows.Forms.Label();
this.item10 = new System.Windows.Forms.Label();
this.item9 = new System.Windows.Forms.Label();
this.item12 = new System.Windows.Forms.Label();
this.back3 = new AxWMPLib.AxWindowsMediaPlayer();
this.label5 = new System.Windows.Forms.Label();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.itemx = new System.Windows.Forms.PictureBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer4 = new System.Windows.Forms.Timer(this.components);
this.timer5 = new System.Windows.Forms.Timer(this.components);
this.label6 = new System.Windows.Forms.Label();
this.pictureBox5 = new System.Windows.Forms.PictureBox();
this.pictureBox6 = new System.Windows.Forms.PictureBox();
this.label7 = new System.Windows.Forms.Label();
this.pictureBox7 = new System.Windows.Forms.PictureBox();
this.label8 = new System.Windows.Forms.Label();
this.pictureBox8 = new System.Windows.Forms.PictureBox();
this.label10 = new System.Windows.Forms.Label();
this.pictureBox9 = new System.Windows.Forms.PictureBox();
this.label11 = new System.Windows.Forms.Label();
this.pictureBox10 = new System.Windows.Forms.PictureBox();
this.label12 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.wmp)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.back)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.back2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.back3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.itemx)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox8)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox9)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox10)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(1043, 281);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(47, 16);
this.label1.TabIndex = 1;
this.label1.Text = "FUCK";
//
// wmp
//
this.wmp.Enabled = true;
this.wmp.Location = new System.Drawing.Point(954, 370);
this.wmp.Name = "wmp";
this.wmp.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wmp.OcxState")));
this.wmp.Size = new System.Drawing.Size(75, 23);
this.wmp.TabIndex = 2;
this.wmp.Visible = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.label2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.label2.Location = new System.Drawing.Point(500, 389);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(35, 13);
this.label2.TabIndex = 3;
this.label2.Text = "label2";
this.label2.Visible = false;
//
// timer2
//
this.timer2.Enabled = true;
this.timer2.Interval = 1;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// timer3
//
this.timer3.Enabled = true;
this.timer3.Tick += new System.EventHandler(this.timer3_Tick);
//
// label9
//
this.label9.BackColor = System.Drawing.Color.White;
this.label9.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.label9.Location = new System.Drawing.Point(12, 510);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(639, 132);
this.label9.TabIndex = 14;
this.label9.Text = "label9";
this.label9.Visible = false;
//
// back
//
this.back.Enabled = true;
this.back.Location = new System.Drawing.Point(907, 414);
this.back.Name = "back";
this.back.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("back.OcxState")));
this.back.Size = new System.Drawing.Size(75, 23);
this.back.TabIndex = 15;
this.back.Visible = false;
//
// back2
//
this.back2.Enabled = true;
this.back2.Location = new System.Drawing.Point(698, 455);
this.back2.Name = "back2";
this.back2.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("back2.OcxState")));
this.back2.Size = new System.Drawing.Size(284, 23);
this.back2.TabIndex = 16;
this.back2.Visible = false;
this.back2.StatusChange += new System.EventHandler(this.back2_StatusChange);
//
// label3
//
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.Color.WhiteSmoke;
this.label3.Font = new System.Drawing.Font("Stencil", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(541, 34);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(85, 42);
this.label3.TabIndex = 19;
this.label3.Text = "BAG";
this.label3.Visible = false;
//
// label4
//
this.label4.AutoSize = true;
this.label4.BackColor = System.Drawing.Color.WhiteSmoke;
this.label4.Font = new System.Drawing.Font("Stencil", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(542, 90);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(109, 42);
this.label4.TabIndex = 20;
this.label4.Text = "POKE";
this.label4.Visible = false;
//
// item0
//
this.item0.AutoSize = true;
this.item0.BackColor = System.Drawing.Color.WhiteSmoke;
this.item0.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item0.Location = new System.Drawing.Point(54, 132);
this.item0.Name = "item0";
this.item0.Size = new System.Drawing.Size(41, 31);
this.item0.TabIndex = 22;
this.item0.Text = "---";
this.item0.Visible = false;
//
// item1
//
this.item1.AutoSize = true;
this.item1.BackColor = System.Drawing.Color.WhiteSmoke;
this.item1.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item1.Location = new System.Drawing.Point(195, 132);
this.item1.Name = "item1";
this.item1.Size = new System.Drawing.Size(41, 31);
this.item1.TabIndex = 23;
this.item1.Text = "---";
this.item1.Visible = false;
//
// item2
//
this.item2.AutoSize = true;
this.item2.BackColor = System.Drawing.Color.WhiteSmoke;
this.item2.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item2.Location = new System.Drawing.Point(336, 132);
this.item2.Name = "item2";
this.item2.Size = new System.Drawing.Size(41, 31);
this.item2.TabIndex = 24;
this.item2.Text = "---";
this.item2.Visible = false;
//
// item5
//
this.item5.AutoSize = true;
this.item5.BackColor = System.Drawing.Color.WhiteSmoke;
this.item5.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item5.Location = new System.Drawing.Point(336, 225);
this.item5.Name = "item5";
this.item5.Size = new System.Drawing.Size(41, 31);
this.item5.TabIndex = 27;
this.item5.Text = "---";
this.item5.Visible = false;
//
// item4
//
this.item4.AutoSize = true;
this.item4.BackColor = System.Drawing.Color.WhiteSmoke;
this.item4.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item4.Location = new System.Drawing.Point(195, 225);
this.item4.Name = "item4";
this.item4.Size = new System.Drawing.Size(41, 31);
this.item4.TabIndex = 26;
this.item4.Text = "---";
this.item4.Visible = false;
//
// item3
//
this.item3.AutoSize = true;
this.item3.BackColor = System.Drawing.Color.WhiteSmoke;
this.item3.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item3.Location = new System.Drawing.Point(54, 225);
this.item3.Name = "item3";
this.item3.Size = new System.Drawing.Size(41, 31);
this.item3.TabIndex = 25;
this.item3.Text = "---";
this.item3.Visible = false;
//
// item8
//
this.item8.AutoSize = true;
this.item8.BackColor = System.Drawing.Color.WhiteSmoke;
this.item8.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item8.Location = new System.Drawing.Point(336, 318);
this.item8.Name = "item8";
this.item8.Size = new System.Drawing.Size(41, 31);
this.item8.TabIndex = 30;
this.item8.Text = "---";
this.item8.Visible = false;
//
// item7
//
this.item7.AutoSize = true;
this.item7.BackColor = System.Drawing.Color.WhiteSmoke;
this.item7.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item7.Location = new System.Drawing.Point(195, 318);
this.item7.Name = "item7";
this.item7.Size = new System.Drawing.Size(41, 31);
this.item7.TabIndex = 29;
this.item7.Text = "---";
this.item7.Visible = false;
//
// item6
//
this.item6.AutoSize = true;
this.item6.BackColor = System.Drawing.Color.WhiteSmoke;
this.item6.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item6.Location = new System.Drawing.Point(54, 318);
this.item6.Name = "item6";
this.item6.Size = new System.Drawing.Size(41, 31);
this.item6.TabIndex = 28;
this.item6.Text = "---";
this.item6.Visible = false;
//
// item11
//
this.item11.AutoSize = true;
this.item11.BackColor = System.Drawing.Color.WhiteSmoke;
this.item11.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item11.Location = new System.Drawing.Point(336, 411);
this.item11.Name = "item11";
this.item11.Size = new System.Drawing.Size(41, 31);
this.item11.TabIndex = 33;
this.item11.Text = "---";
this.item11.Visible = false;
//
// item10
//
this.item10.AutoSize = true;
this.item10.BackColor = System.Drawing.Color.WhiteSmoke;
this.item10.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item10.Location = new System.Drawing.Point(195, 411);
this.item10.Name = "item10";
this.item10.Size = new System.Drawing.Size(41, 31);
this.item10.TabIndex = 32;
this.item10.Text = "---";
this.item10.Visible = false;
//
// item9
//
this.item9.AutoSize = true;
this.item9.BackColor = System.Drawing.Color.WhiteSmoke;
this.item9.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item9.Location = new System.Drawing.Point(54, 411);
this.item9.Name = "item9";
this.item9.Size = new System.Drawing.Size(41, 31);
this.item9.TabIndex = 31;
this.item9.Text = "---";
this.item9.Visible = false;
//
// item12
//
this.item12.AutoSize = true;
this.item12.BackColor = System.Drawing.Color.WhiteSmoke;
this.item12.Font = new System.Drawing.Font("WenQuanYi Micro Hei", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(136)));
this.item12.Location = new System.Drawing.Point(40, 43);
this.item12.Name = "item12";
this.item12.Size = new System.Drawing.Size(47, 38);
this.item12.TabIndex = 34;
this.item12.Text = "---";
this.item12.Visible = false;
//
// back3
//
this.back3.Enabled = true;
this.back3.Location = new System.Drawing.Point(698, 484);
this.back3.Name = "back3";
this.back3.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("back3.OcxState")));
this.back3.Size = new System.Drawing.Size(284, 23);
this.back3.TabIndex = 35;
this.back3.Visible = false;
//
// label5
//
this.label5.AutoSize = true;
this.label5.BackColor = System.Drawing.Color.WhiteSmoke;
this.label5.Font = new System.Drawing.Font("Stencil", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(517, 284);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(38, 16);
this.label5.TabIndex = 36;
this.label5.Text = "MAP:";
this.label5.Visible = false;
//
// pictureBox4
//
this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
this.pictureBox4.Location = new System.Drawing.Point(517, 43);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(18, 24);
this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox4.TabIndex = 18;
this.pictureBox4.TabStop = false;
this.pictureBox4.Visible = false;
this.pictureBox4.Move += new System.EventHandler(this.pictureBox4_Move);
//
// pictureBox3
//
this.pictureBox3.Image = global::pokemon.Properties.Resources.menu2;
this.pictureBox3.Location = new System.Drawing.Point(496, 12);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(177, 374);
this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox3.TabIndex = 17;
this.pictureBox3.TabStop = false;
this.pictureBox3.Visible = false;
this.pictureBox3.VisibleChanged += new System.EventHandler(this.pictureBox3_VisibleChanged);
//
// pictureBox2
//
this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(-3, 501);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(692, 159);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox2.TabIndex = 13;
this.pictureBox2.TabStop = false;
this.pictureBox2.Visible = false;
this.pictureBox2.VisibleChanged += new System.EventHandler(this.pictureBox2_VisibleChanged);
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(874, 34);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(274, 280);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.Visible = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// itemx
//
this.itemx.Image = global::pokemon.Properties.Resources.menu;
this.itemx.Location = new System.Drawing.Point(12, 12);
this.itemx.Name = "itemx";
this.itemx.Size = new System.Drawing.Size(465, 466);
this.itemx.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.itemx.TabIndex = 21;
this.itemx.TabStop = false;
this.itemx.Visible = false;
this.itemx.VisibleChanged += new System.EventHandler(this.pictureBox5_VisibleChanged);
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// timer4
//
this.timer4.Tick += new System.EventHandler(this.timer4_Tick);
//
// timer5
//
this.timer5.Tick += new System.EventHandler(this.timer5_Tick);
//
// label6
//
this.label6.AutoSize = true;
this.label6.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.label6.Font = new System.Drawing.Font("Miramonte", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label6.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.label6.Location = new System.Drawing.Point(80, 519);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(534, 78);
this.label6.TabIndex = 38;
this.label6.Text = "PUSH Z BUTTON";
//
// pictureBox5
//
this.pictureBox5.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox5.Image")));
this.pictureBox5.Location = new System.Drawing.Point(0, 0);
this.pictureBox5.Name = "pictureBox5";
this.pictureBox5.Size = new System.Drawing.Size(685, 660);
this.pictureBox5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox5.TabIndex = 39;
this.pictureBox5.TabStop = false;
this.pictureBox5.Visible = false;
this.pictureBox5.VisibleChanged += new System.EventHandler(this.pictureBox5_VisibleChanged_1);
this.pictureBox5.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox5_Paint);
//
// pictureBox6
//
this.pictureBox6.BackColor = System.Drawing.Color.Teal;
this.pictureBox6.Image = global::pokemon.Properties.Resources._1231;
this.pictureBox6.Location = new System.Drawing.Point(212, 43);
this.pictureBox6.Name = "pictureBox6";
this.pictureBox6.Size = new System.Drawing.Size(450, 72);
this.pictureBox6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox6.TabIndex = 40;
this.pictureBox6.TabStop = false;
this.pictureBox6.Visible = false;
this.pictureBox6.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox6_Paint);
//
// label7
//
this.label7.AutoSize = true;
this.label7.BackColor = System.Drawing.Color.LightSkyBlue;
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label7.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.label7.Location = new System.Drawing.Point(512, 86);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(22, 29);
this.label7.TabIndex = 41;
this.label7.Text = "-";
this.label7.Visible = false;
//
// pictureBox7
//
this.pictureBox7.BackColor = System.Drawing.Color.Teal;
this.pictureBox7.Image = global::pokemon.Properties.Resources._1231;
this.pictureBox7.Location = new System.Drawing.Point(212, 159);
this.pictureBox7.Name = "pictureBox7";
this.pictureBox7.Size = new System.Drawing.Size(450, 72);
this.pictureBox7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox7.TabIndex = 42;
this.pictureBox7.TabStop = false;
this.pictureBox7.Visible = false;
this.pictureBox7.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox7_Paint);
//
// label8
//
this.label8.AutoSize = true;
this.label8.BackColor = System.Drawing.Color.LightSkyBlue;
this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label8.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.label8.Location = new System.Drawing.Point(512, 208);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(22, 29);
this.label8.TabIndex = 43;
this.label8.Text = "-";
this.label8.Visible = false;
//
// pictureBox8
//
this.pictureBox8.BackColor = System.Drawing.Color.Teal;
this.pictureBox8.Image = global::pokemon.Properties.Resources._1231;
this.pictureBox8.Location = new System.Drawing.Point(212, 275);
this.pictureBox8.Name = "pictureBox8";
this.pictureBox8.Size = new System.Drawing.Size(450, 72);
this.pictureBox8.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox8.TabIndex = 44;
this.pictureBox8.TabStop = false;
this.pictureBox8.Visible = false;
this.pictureBox8.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox8_Paint);
//
// label10
//
this.label10.AutoSize = true;
this.label10.BackColor = System.Drawing.Color.LightSkyBlue;
this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label10.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.label10.Location = new System.Drawing.Point(512, 326);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(22, 29);
this.label10.TabIndex = 45;
this.label10.Text = "-";
this.label10.Visible = false;
//
// pictureBox9
//
this.pictureBox9.BackColor = System.Drawing.Color.Teal;
this.pictureBox9.Image = global::pokemon.Properties.Resources._1231;
this.pictureBox9.Location = new System.Drawing.Point(212, 391);
this.pictureBox9.Name = "pictureBox9";
this.pictureBox9.Size = new System.Drawing.Size(450, 72);
this.pictureBox9.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox9.TabIndex = 46;
this.pictureBox9.TabStop = false;
this.pictureBox9.Visible = false;
this.pictureBox9.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox9_Paint);
//
// label11
//
this.label11.AutoSize = true;
this.label11.BackColor = System.Drawing.Color.LightSkyBlue;
this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label11.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.label11.Location = new System.Drawing.Point(512, 447);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(22, 29);
this.label11.TabIndex = 47;
this.label11.Text = "-";
this.label11.Visible = false;
//
// pictureBox10
//
this.pictureBox10.BackColor = System.Drawing.Color.Teal;
this.pictureBox10.Image = global::pokemon.Properties.Resources._1231;
this.pictureBox10.Location = new System.Drawing.Point(212, 507);
this.pictureBox10.Name = "pictureBox10";
this.pictureBox10.Size = new System.Drawing.Size(450, 72);
this.pictureBox10.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox10.TabIndex = 48;
this.pictureBox10.TabStop = false;
this.pictureBox10.Visible = false;
this.pictureBox10.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox10_Paint);
//
// label12
//
this.label12.AutoSize = true;
this.label12.BackColor = System.Drawing.Color.LightSkyBlue;
this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label12.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.label12.Location = new System.Drawing.Point(512, 562);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(22, 29);
this.label12.TabIndex = 49;
this.label12.Text = "-";
this.label12.Visible = false;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ButtonFace;
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(684, 661);
this.Controls.Add(this.label10);
this.Controls.Add(this.label7);
this.Controls.Add(this.pictureBox6);
this.Controls.Add(this.label8);
this.Controls.Add(this.label12);
this.Controls.Add(this.pictureBox10);
this.Controls.Add(this.label11);
this.Controls.Add(this.pictureBox9);
this.Controls.Add(this.pictureBox8);
this.Controls.Add(this.pictureBox7);
this.Controls.Add(this.pictureBox5);
this.Controls.Add(this.label6);
this.Controls.Add(this.item12);
this.Controls.Add(this.item11);
this.Controls.Add(this.item10);
this.Controls.Add(this.item9);
this.Controls.Add(this.item8);
this.Controls.Add(this.item7);
this.Controls.Add(this.item6);
this.Controls.Add(this.item5);
this.Controls.Add(this.item4);
this.Controls.Add(this.item3);
this.Controls.Add(this.item2);
this.Controls.Add(this.item1);
this.Controls.Add(this.item0);
this.Controls.Add(this.label5);
this.Controls.Add(this.back3);
this.Controls.Add(this.pictureBox4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.pictureBox3);
this.Controls.Add(this.back2);
this.Controls.Add(this.back);
this.Controls.Add(this.label9);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.label2);
this.Controls.Add(this.wmp);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.itemx);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Pokemon";
this.Load += new System.EventHandler(this.Form1_Load);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyUp);
((System.ComponentModel.ISupportInitialize)(this.wmp)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.back)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.back2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.back3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.itemx)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox8)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox9)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox10)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label1;
private AxWMPLib.AxWindowsMediaPlayer wmp;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.Timer timer3;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.Label label9;
private AxWMPLib.AxWindowsMediaPlayer back;
private AxWMPLib.AxWindowsMediaPlayer back2;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBox4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.PictureBox itemx;
private System.Windows.Forms.Label item0;
private System.Windows.Forms.Label item1;
private System.Windows.Forms.Label item2;
private System.Windows.Forms.Label item5;
private System.Windows.Forms.Label item4;
private System.Windows.Forms.Label item3;
private System.Windows.Forms.Label item8;
private System.Windows.Forms.Label item7;
private System.Windows.Forms.Label item6;
private System.Windows.Forms.Label item11;
private System.Windows.Forms.Label item10;
private System.Windows.Forms.Label item9;
private System.Windows.Forms.Label item12;
private AxWMPLib.AxWindowsMediaPlayer back3;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Timer timer4;
private System.Windows.Forms.Timer timer5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.PictureBox pictureBox5;
private System.Windows.Forms.PictureBox pictureBox6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.PictureBox pictureBox7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.PictureBox pictureBox8;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.PictureBox pictureBox9;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.PictureBox pictureBox10;
private System.Windows.Forms.Label label12;
}
}
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
view raw Program.cs hosted with ❤ by GitHub


Java_battole tetris

又是一次課堂專題


在看到了fb小遊戲,因為課堂專題需要所以來做個小練習
可以單人和雙人對打喔!為什麼沒計分系統? 自己寫拉
單人
雙人

battole tetris.code



package ti;
import java.lang.Thread;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
import javax.swing.*;
import ti.SocketClient;
import ti.SocketServer;
public class game extends JFrame implements MouseListener {
public final int WIDTH = 800, HEIGHT = 500;
public JButton button = new JButton("button");
public static String client_ip = "127.0.0.1";
public static int server_port = 1234; // server port
public static int client_port = 1234; // client port
public SocketServer server;
public SocketClient client;
public boolean online = false;
public boolean isserver = false;
public static boolean first_data = false;
public static boolean changeing = false;
public static boolean single = false;
public static game tmp;
public final JMenuItem[] gm = new JMenuItem[5];// ���1
GamePanel panel = new GamePanel();
ImageIcon image = new ImageIcon("TetrisImg/single.png");
ImageIcon image2 = new ImageIcon("TetrisImg/double.png");
JLabel l1 = new JLabel(image);
JLabel l2 = new JLabel(image2);
JPanel mainpanel = new JPanel();
public static game gui;
private Component add;
public game() {
///
this.setTitle("Game Test");
this.setSize(WIDTH, HEIGHT);
this.setLayout(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainpanel.setLayout(new GridLayout(2, 1));
mainpanel.setSize(250, 130);
this.setResizable(false);
this.setLocationRelativeTo(null);
mainpanel.add(l1);
mainpanel.add(l2);
this.add(mainpanel);
mainpanel.setLocation((WIDTH / 2) - 125, (HEIGHT / 2) - 130);
l1.addMouseListener(this);
l2.addMouseListener(this);
JMenuBar jmb = new JMenuBar();
gm[0] = new JMenuItem("���A�����e");
gm[1] = new JMenuItem("�s�u");
gm[2] = new JMenuItem("�C�����");
gm[3] = new JMenuItem("�Ȱ�");
gm[4] = new JMenuItem("�~��");
JMenu game = new JMenu("�C���ﶵ");
gm[2].setEnabled(false);
game.add(gm[0]);
game.add(gm[1]);
game.add(gm[2]);
game.add(gm[3]);
game.add(gm[4]);
server = new SocketServer();
server.start();
gm[0].addActionListener(new ActionListener() {
// �ƥ�B�z
@Override
public void actionPerformed(ActionEvent e) {
// server_thread t1 = new server_thread();
// t1.start();
try {
JOptionPane.showMessageDialog(game.this,
"�z��ip�ثe�O : " + InetAddress.getLocalHost().getHostAddress() + "\n" + "���b���ݹ��s���C\n");
} catch (HeadlessException | UnknownHostException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
gm[1].addActionListener(new ActionListener() {
// �ƥ�B�z
@Override
public void actionPerformed(ActionEvent e) {
int mType = JOptionPane.INFORMATION_MESSAGE;
String tmp = JOptionPane.showInputDialog(game.this, "�п�J�n�s�u��ip", "��J", mType);
JOptionPane.showMessageDialog(game.this, "�z��J���O : " + tmp);
if (tmp != null)
client_ip = tmp;
/*
* tmp = JOptionPane.showInputDialog(game.this, "�п�J�n�s�u���ݤf",
* "��J", mType); JOptionPane.showMessageDialog(game.this,
* "�z��J���O : " + tmp); if (tmp != null) client_port =
* Integer.valueOf(tmp);
*/
server.Client_ip = client_ip;
gm[2].setEnabled(true);
online = true;
// client_thread t2 = new client_thread();
// t2.start();*/
}
});
gm[2].addActionListener(new ActionListener() {
// �ƥ�B�z
@Override
public void actionPerformed(ActionEvent e) {
mainpanel.setVisible(true);
panel.requestFocus();
gui.panel.timer.stop();
gui.panel.timer2.stop();
gui.panel.setVisible(false);
setSize(800, 500);
}
});
gm[3].addActionListener(new ActionListener() {
// �ƥ�B�z
@Override
public void actionPerformed(ActionEvent e) {
gui.panel.timer.stop();
gui.panel.timer2.stop();
}
});
gm[4].addActionListener(new ActionListener() {
// �ƥ�B�z
@Override
public void actionPerformed(ActionEvent e) {
gui.panel.timer.start();
gui.panel.timer2.start();
}
});
jmb.add(game);
// jmb.add(about);
this.setJMenuBar(jmb);
panel.setBounds(0, 0, 800, 500);
addKeyListener(panel);
// add(panel);
////////////////
}
public static void main(String[] args) {
gui = new game();
gui.setVisible(true);
}
public void focus() {
mainpanel.setVisible(false);
requestFocus();
add(panel);
}
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
JLabel sel = (JLabel) arg0.getSource();
if (sel == l1) {
this.setSize(400, 500);
focus();
panel.setBounds(0, 0, 400, 500);
single = true;
gm[2].setEnabled(true);
gui.panel.setVisible(true);
isserver = false;
gui.panel.set_zero();
gui.panel.timer.start();
gui.panel.timer2.start();
focus();
} else if (sel == l2) {
this.setSize(800, 500);
panel.setBounds(0, 0, 800, 500);
single = false;
gm[2].setEnabled(true);
gui.panel.setVisible(true);
isserver = true;
gui.panel.set_zero();
gui.panel.timer.start();
gui.panel.timer2.start();
focus();
}
}
@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
/*
* public class server_thread extends Thread {
*
* public void run() { // server = new SocketServer(server_port);
*
* } }
*
* public class client_thread extends Thread {
*
* public void run() {
*
* client = new SocketClient(client_ip, client_port, null);
*
* } }
*/
class GamePanel extends JPanel implements KeyListener {
public int[][] map = new int[10][20];
public int[][] map2 = new int[10][20];
private int shapes1[][][] = new int[8][5][18];
private int shapes2[][][] = new int[8][5][18];
private int blockType;
private int turnState;
private int blockType2;
private int turnState2;
private int now_playx = 0;
private int now_playy = 0;
private int now_play2x = -100;
private int now_play2y = -100;
private int tmpplay2x = -100;
private int tmpplay2y = -100;
private int x, y, hold, next, change;
private int flag = 0;
public Timer timer = new Timer(500, new TimerListener());
public Timer timer2 = new Timer(50, new ping());
private boolean get_alldata = false;
private Image b1, b2;
private Image[] color = new Image[7];
public void set_zero() {
now_playx = 0;
now_playy = 0;
now_play2x = -100;
now_play2y = -100;
tmpplay2x = -100;
tmpplay2y = -100;
x = 3;
y = 0;
for (int i = 0; i < 10; i++)
for (int j = 0; j < 20; j++) {
map[i][j] = 0;
map2[i][j] = 0;
}
shapes1 = new int[][][] {
// I
{ { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 },
{ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 } },
// s
{ { 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
// z
{ { 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 } },
// j
{ { 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
// o
{ { 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
// l
{ { 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
// t
{ { 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0 } } };
shapes2 = new int[][][] {
// I
{ { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 },
{ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 } },
// s
{ { 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
// z
{ { 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 } },
// j
{ { 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
// o
{ { 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
// l
{ { 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
// t
{ { 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0 } } };
}
public GamePanel() {
this.setLayout(null);
this.setBackground(Color.BLACK);
b1 = Toolkit.getDefaultToolkit().getImage("TetrisImg/background1.png");
b2 = Toolkit.getDefaultToolkit().getImage("TetrisImg/background2.png");
color[0] = Toolkit.getDefaultToolkit().getImage("TetrisImg/blue.png");
color[1] = Toolkit.getDefaultToolkit().getImage("TetrisImg/green.png");
color[2] = Toolkit.getDefaultToolkit().getImage("TetrisImg/red.png");
color[3] = Toolkit.getDefaultToolkit().getImage("TetrisImg/deepblue.png");
color[4] = Toolkit.getDefaultToolkit().getImage("TetrisImg/yellow.png");
color[5] = Toolkit.getDefaultToolkit().getImage("TetrisImg/orange.png");
color[6] = Toolkit.getDefaultToolkit().getImage("TetrisImg/pink.png");
JLabel NEXT = new JLabel("NEXT");
NEXT.setFont(new Font("", Font.BOLD, 25));
NEXT.setBounds(200, 0, 100, 100);
NEXT.setForeground(Color.white);
add(NEXT);
JLabel HOLD = new JLabel("HOLD");
HOLD.setFont(new Font("", Font.BOLD, 25));
HOLD.setBounds(300, 0, 100, 100);
HOLD.setForeground(Color.white);
add(HOLD);
initMap();
newBlock();
hold = -1;
next = (int) (Math.random() * 7);
timer.start();
timer2.start();
}
public void newBlock() {
flag = 0;
blockType = next;
change = 1;
next = (int) (Math.random() * 7);
turnState = 0;
x = 3;
y = 0;
if (gameOver(x, y) == 1) {
initMap();
// JOptionPane.showMessageDialog(null, "GAME OVER");
}
repaint();
}
public void setBlock(int x, int y, int type, int state) {
flag = 1;
first_data = true;
for (int i = 0; i < 16; i++) {
if (shapes1[type][state][i] == 1) {
map[x + i % 4][y + i / 4] = type + 1;
System.out.println("shape[" + type + "][" + state + "][" + i + "]");
System.out.println("map[" + x + i % 4 + "][" + y + i / 4 + "]=" + type + 1);
}
}
}
public int gameOver(int x, int y) {
if (blow(x, y, blockType, turnState) == 0)
return 1;
return 0;
}
public int blow(int x, int y, int type, int state) {
for (int i = 0; i < 16; i++) {
if (shapes1[type][state][i] == 1) {
if (x + i % 4 >= 10 || y + i / 4 >= 20 || x + i % 4 < 0 || y + i / 4 < 0)
return 0;
if (map[x + i % 4][y + i / 4] != 0)
return 0;
}
}
return 1;
}
public void rotate() {
int tmpState = this.turnState;
tmpState = (tmpState + 1) % 4;
if (blow(x, y, this.blockType, tmpState) == 1) {
this.turnState = tmpState;
}
repaint();
}
public int r_shift() {
int canShift = 0;
if (blow(x + 1, y, blockType, turnState) == 1) {
x++;
canShift = 1;
}
repaint();
return canShift;
}
public void l_shift() {
if (blow(x - 1, y, blockType, turnState) == 1) {
x--;
}
repaint();
}
public int down_shift() {
int canDown = 0;
if (blow(x, y + 1, blockType, turnState) == 1) {
y++;
canDown = 1;
}
repaint();
if (blow(x, y + 1, blockType, turnState) == 0) {
// Sleep(500);
setBlock(x, y, blockType, turnState);
newBlock();
delLine();
canDown = 0;
}
return canDown;
}
void delLine() {
int idx = 19, access = 0;
for (int i = 19; i >= 0; i--) {
int cnt = 0;
for (int j = 0; j < 10; j++) {
if (map[j][i] != 0)
cnt++;
}
if (cnt == 10) {
access = 1;
for (int j = 0; j < 10; j++) {
map[j][i] = 0;
}
} else {
for (int j = 0; j < 10; j++) {
map[j][idx] = map[j][i];
}
idx--;
}
}
/*
* if(access == 1) Sleep(500);
*/
}
void initMap() {
for (int i = 0; i < 10; i++)
for (int j = 0; j < 20; j++)
map[i][j] = 0;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (single == false)
paintComponent2(g);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 20; j++) {
if (map[i][j] == 0) {
if ((i + j) % 2 == 0)
g.drawImage(b1, i * 15 + 3 * (i + 1) + 0, j * 15 + 3 * (j + 1), null);
else
g.drawImage(b2, 0, 0, null);
} else
g.drawImage(color[map[i][j] - 1], i * 15 + 3 * (i + 1) + 0, j * 15 + 3 * (j + 1), null);
}
}
if (flag == 0) {
for (int i = 0; i < 16; i++) {
if (shapes1[blockType][turnState][i] == 1) {
g.drawImage(color[blockType], (i % 4 + x) * 18 + 3 + 0, (i / 4 + y) * 18 + 3, null);
now_playx = x;
now_playy = y;
}
}
}
if (hold >= 0) {
for (int i = 0; i < 16; i++) {
if (shapes1[hold][0][i] == 1) {
g.drawImage(color[hold], (i % 4) * 18 + 200, (i / 4) * 18 + 3 + 80, null);
}
}
}
for (int i = 0; i < 16; i++) {
if (shapes1[next][0][i] == 1) {
g.drawImage(color[next], (i % 4) * 18 + 300, (i / 4) * 18 + 3 + 80, null);
}
}
}
public void paintComponent2(Graphics g) {
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 20; j++) {
if (map2[i][j] == 0) {
if ((i + j) % 2 == 0)
g.drawImage(b1, i * 15 + 3 * (i + 1) + 450, j * 15 + 3 * (j + 1), null);
else
g.drawImage(b2, 0, 0, null);
} else
g.drawImage(color[map2[i][j] - 1], i * 15 + 3 * (i + 1) + 450, j * 15 + 3 * (j + 1), null);
}
}
if (flag == 0) {
for (int i = 0; i < 16; i++) {
if (shapes2[blockType2][turnState2][i] == 1) {
g.drawImage(color[blockType2], (i % 4 + now_play2x) * 18 + 3 + 450,
(i / 4 + now_play2y) * 18 + 3, null);
}
}
}
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_DOWN:
down_shift();
break;
case KeyEvent.VK_UP:
rotate();
break;
case KeyEvent.VK_RIGHT:
r_shift();
break;
case KeyEvent.VK_LEFT:
l_shift();
break;
case KeyEvent.VK_SPACE:
while (down_shift() == 1)
;
break;
case KeyEvent.VK_SHIFT:
if (hold >= 0 && change == 1) {
int tmp;
tmp = hold;
hold = blockType;
blockType = tmp;
x = 3;
y = 0;
change = 0;
} else if (change == 1) {
hold = blockType;
newBlock();
}
break;
}
}
void Sleep(int milliseconds) {
try {
Thread.sleep(milliseconds);
} catch (InterruptedException e) {
System.out.println("Unexcepted interrupt");
System.exit(0);
}
}
class ping implements ActionListener {
public void actionPerformed(ActionEvent e) {
String tmp = "";
// �۩w�q����ƩM�榡
if (first_data == true) {
tmp += "0,";
for (int i = 0; i < 10; i++)
for (int j = 0; j < 20; j++)
tmp += map[i][j] + ",";
first_data = false;
// 0,0,0,0,0,0,0,0.....�a�W��
} else {
tmp += "1,";
tmp += blockType + "," + turnState + ",";
tmp += now_playx + "," + now_playy + ",";
for (int i = 0; i < 16; i++)
tmp += shapes1[blockType][turnState][i] + ",";
}
// 1,0,0,0,0,0,0,0.....�ѤW��
// �ˬdserver �O�_����ƶǤJ
// �����ܧ�����ip
String change_ip = null;
if (server.Client_ip != null)
// �o�@��N�O�qserver socket���ip
change_ip = server.Client_ip;
else
change_ip = null;
//
//�p�G�����o��ip����
if (change_ip != null) {
System.out.println(tmp);
//client socket ���server��client_ip �@���ڭn�o�e���ؼ�ip�]�N�Ochange_ip
// tmp �O�n�o�e�����
client = new SocketClient(change_ip, client_port, tmp);
//server������ư��ѽX
System.out.println(server.getstring());
if (server.getstring() != null && server.getstring() != "") {
String[] tokens = server.getstring().split(",");
int x = 0, count = 0;
int change = -1;
for (String token : tokens) {
if (change == -1)
change = Integer.valueOf(token);
else if (change == 0) {
map2[x][count] = Integer.valueOf(token);
if (count == 19) {
count = 0;
x++;
} else
count++;
} else if (change == 1) {
if (x == 0)
blockType2 = Integer.valueOf(token);
else if (x == 1)
turnState2 = Integer.valueOf(token);
else if (x == 2)
now_play2x = Integer.valueOf(token);
else if (x == 3)
now_play2y = Integer.valueOf(token);
else if (x >= 4) {
shapes2[blockType2][turnState2][count] = Integer.valueOf(token);
count++;
}
x++;
}
}
repaint();
}
}
}
}
class TimerListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
repaint();
down_shift();
// System.out.println(server.get_data);
}
}
}
}
view raw game.java hosted with ❤ by GitHub
package ti;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketException;
import java.io.BufferedOutputStream;
public class SocketClient {
public String address = "127.0.0.1";// �s�u��ip
public int port = 1234;// �s�u��port
Socket client = new Socket();
public SocketClient(String address, int port, String mes) {
InetSocketAddress isa = new InetSocketAddress(address, port);
try {
client.connect(isa, 80);
BufferedOutputStream out = new BufferedOutputStream(client.getOutputStream());
// �e�X�r��
try {
client.setTcpNoDelay(true);
client.setReceiveBufferSize(16);
client.setSendBufferSize(23);
client.setKeepAlive(true);
client.setPerformancePreferences(1, 2, 0);
} catch (SocketException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
out.write(mes.getBytes());
out.flush();
out.close();
out = null;
client.close();
client = null;
} catch (java.io.IOException e) {
System.out.println("Socket�s�u�����D !");
System.out.println("IOException :" + e.toString());
}
}
public void set_ipport(String ADDRESS, int port) {
this.address = ADDRESS;
this.port = port;
}
}
package ti;
import java.awt.EventQueue;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
public class SocketServer extends Thread {
private boolean running = false;
private boolean OutServer = false;
private ServerSocket server;
private static int ServerPort = 1234;// �n�ʱ���port
public static String test;
public static String test2;
public static String Client_ip = null;
Thread serverThread;
public SocketServer() {
try {
server = new ServerSocket(ServerPort);
} catch (java.io.IOException e) {
System.out.println("Socket�Ұʦ����D !");
System.out.println("IOException :" + e.toString());
}
}
public void stop_thread() {
OutServer = false;
}
public void run() {
Socket socket;
running = false;
java.io.BufferedInputStream in;
System.out.println("���A���w�Ұ� !");
while (!OutServer) {
System.out.println(ServerPort);
socket = null;
try {
synchronized (server) {
socket = server.accept();
}
try {
socket.setTcpNoDelay(true);
socket.setReceiveBufferSize(23);
socket.setSendBufferSize(16);
socket.setKeepAlive(true);
socket.setPerformancePreferences(1, 2, 0);
} catch (SocketException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// TimeOut�ɶ�
socket.setSoTimeout(10000);
Client_ip = null;
Client_ip = socket.getInetAddress().getHostAddress();// ����o�e��ip
//��Ʀ�y�����r��
System.out.println("���o�s�u : InetAddress = " + socket.getInetAddress().getHostAddress());
in = new java.io.BufferedInputStream(socket.getInputStream());
byte[] b = new byte[256];
String data = "";
int length;
while ((length = in.read(b)) > 0)// <=0���ܴN�O�����F
{
data += new String(b, 0, length);
}
test = (data);
in.close();
in = null;
socket.close();
} catch (java.io.IOException e) {
System.out.println("Socket�s�u�����D !");
System.out.println("IOException :" + e.toString());
}
}
}
public String getstring() {
return test;
}
public String getstring2() {
return test2;
}
public boolean isRunning() {
return running;
}
}

Java_message

即時通


相信大家都有用過Yahoo即時通,那時候還有一個漏洞呢,輸入超過很多字元會讓對方斷線
,那麼我們來土炮一個來看看吧!




message.code


package messager;
import java.awt.EventQueue;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTree;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JTextField;
import java.awt.Font;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultMutableTreeNode;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JScrollPane;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JTabbedPane;
public class main extends JFrame {
public String IP;
public static String data_ip;
public static String local_ip = null;
public String send_ip = null;
public int send_port = 9000;
public String msg;
private JPanel contentPane;
private JTextField textField;
private final Action action = new SwingAction();
public static String user;
public static String password;
public String mysqlback_friends = null;
public SocketServer task = new SocketServer();
public Thread t = new Thread(task); // 產生Thread物件
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
main frame = new main(user, password, data_ip,local_ip);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void mysql_exc(String exc) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(
"jdbc:mysql://"+this.data_ip+"/messager?useUnicode=true&characterEncoding=UTF8", "root",
"x123456789");
Statement st = con.createStatement();
ResultSet rs = st.getResultSet();
st.execute(exc);
rs = st.getResultSet();
} catch (ClassNotFoundException o) {
System.out.println("DriverClassNotFound :" + o.toString());
} // 有可能會產生sqlexception
catch (SQLException x) {
System.out.println("Exception :" + x.toString());
}
}
public main(String user, String password, String data_ip,String local_ip) {
this.user = user;
this.password = password;
this.data_ip = data_ip;
this.local_ip= local_ip;
JMenuBar menuBar = new JMenuBar();
JButton btnNewButton = new JButton("+");
JPanel panel = new JPanel();
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
String tmp2 = mysql_search("SELECT * FROM user where id='" + user + "' &&" + " password='" + password + "'","friends");
JTree tree = new JTree();
JScrollPane scrollPane = new JScrollPane();
JMenu mnNewMenu = new JMenu("即時通");
JMenuItem item = new JMenuItem("登出");
mysql_exc("UPDATE user SET port = '"+send_port+"' where id='" + user + "' &&" + " password='" + password + "'");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mysql_exc("UPDATE user SET online = '0' where id='" + user + "' &&" + " password='" + password + "'");
System.exit(0);
}
});
mysql_exc("UPDATE user SET ip = '"+local_ip+"' where id='" + user + "' &&" + " password='" + password + "'");
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
setBounds(100, 100, 249, 414);
setJMenuBar(menuBar);
menuBar.add(mnNewMenu);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
mnNewMenu.add(item);
btnNewButton.setFont(new Font("微軟正黑體", Font.PLAIN, 9));
textField = new JTextField();
textField.setColumns(10);
JScrollPane scrollPane_1 = new JScrollPane();
JTree tree_1 = new JTree();
tree_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree_1.getLastSelectedPathComponent();
if (node == null)
return;
Object nodeInfo = node.getUserObject();// 通訊點入那個當client
if (!nodeInfo.toString().equals("好友清單")) {
IP = nodeInfo.toString();
new SocketClient();
}
}
});
scrollPane_1.setViewportView(tree_1);
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
DefaultTreeModel model = (DefaultTreeModel) tree_1.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
if (!textField.getText().trim().equals("")) {
root.add(new DefaultMutableTreeNode(textField.getText()));
model.reload();
}
else {
JOptionPane.showMessageDialog(null, "fuck dick");
}
}
});
GroupLayout gl_panel = new GroupLayout(panel);
JTabbedPane tabbedPane_1 = new JTabbedPane(JTabbedPane.TOP);
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(7)
.addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(5)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(5)
.addComponent(btnNewButton)
.addGap(5)
.addComponent(tabbedPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addContainerGap(69, Short.MAX_VALUE))
.addComponent(tabbedPane_1, GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(5)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(6)
.addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(btnNewButton)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(8)
.addComponent(tabbedPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(tabbedPane_1, GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE))
);
tabbedPane_1.addTab("New tab", null, scrollPane_1, null);
tree_1.setModel(new DefaultTreeModel(
new DefaultMutableTreeNode("廢物群") {
{
String tmp = tmp2;
String[] tokens = tmp.split(",");
for (String token : tokens) {
add(new DefaultMutableTreeNode(token));
}
}
}
));
this.setVisible(true);
contentPane.setLayout(gl_contentPane);
t.start();
}
public String mysql_search(String exc,String label) {
String tmp = null;
try {
Class.forName("com.mysql.jdbc.Driver");
// 註冊driver
Connection con = DriverManager.getConnection(
"jdbc:mysql://"+this.data_ip+"/messager?useUnicode=true&characterEncoding=UTF8", "root",
"x123456789");
// 取得connection
Statement st = con.createStatement();
st.execute(exc);
ResultSet rs = st.getResultSet();
while (rs.next()) {
tmp = rs.getString(label);
}
if (tmp == null) {
JOptionPane.showMessageDialog(null, "與伺服器取得資料失敗!");
} else
return tmp;
} catch (ClassNotFoundException o) {
System.out.println("DriverClassNotFound :" + o.toString());
} // 有可能會產生sqlexception
catch (SQLException x) {
System.out.println("Exception :" + x.toString());
}
return tmp;
}
private class SwingAction extends AbstractAction {
public SwingAction() {
putValue(NAME, "SwingAction");
putValue(SHORT_DESCRIPTION, "Some short description");
}
public void actionPerformed(ActionEvent e) {
}
}
public class SocketServer extends java.lang.Thread {
private boolean OutServer = false;
private ServerSocket server;
private final int ServerPort = 10000;// 要監控的port
public SocketServer() {
try {
server = new ServerSocket(ServerPort);
} catch (java.io.IOException e) {
System.out.println("Socket啟動有問題 !");
System.out.println("IOException :" + e.toString());
}
}
public void run() {
InputStreamReader inSR = null;
OutputStreamWriter outSW = null;
Socket socket;
java.io.BufferedInputStream in;
System.out.println("監聽伺服器已啟動 !");
while (!OutServer) {
socket = null;
try {
synchronized (server) {
socket = server.accept();
}
System.out.println("取得連線 : InetAddress = " + socket.getInetAddress());
// TimeOut時間
socket.setSoTimeout(15000);
inSR = new InputStreamReader(socket.getInputStream(), "UTF-8");
BufferedReader br = new BufferedReader(inSR);
in = new java.io.BufferedInputStream(socket.getInputStream());
byte[] b = new byte[1024];
String data = "";
int length;
while ((length = in.read(b)) > 0)// <=0的話就是結束了
{
data += new String(b, 0, length, "big5");// 注意編碼
}
String tmp = data;
String[] tokens = data.split(":");
//String tmp3 = mysql_search("SELECT * FROM user where id='" +Integer.valueOf(tokens[1])+ "'","port");
//if(Integer.valueOf(tmp3 )>send_port)
send_port=Integer.valueOf(Integer.valueOf(tokens[1]));
send_ip = tokens[0];
new_message(send_ip, send_port);
String tmp2 = "確實收到資料" + send_ip + ":" + tokens[1];
System.out.print(tmp2);
in.close();
in = null;
socket.close();
} catch (java.io.IOException e) {
System.out.println("Socket連線有問題 !");
System.out.println("IOException :" + e.toString());
}
}
server = null;
}
public void stopThread() throws IOException {
server.close();
this.OutServer = true;
}
}
public void new_message(String ip, int port) {
msg test = new msg(ip,port);
test.setTitle(ip);
send_port++;
}
public class SocketClient extends java.lang.Thread {
private String address = IP;// 連線的ip
private int port = 10000;// 連線的port
public SocketClient() {
Socket client = new Socket();
InetSocketAddress isa = new InetSocketAddress(this.address, this.port);
try {
client.connect(isa,10000);
BufferedOutputStream out = new BufferedOutputStream(client.getOutputStream());
// 送出字串
String tmp =local_ip+ ":" + String.valueOf(send_port);
System.out.print("已向對方發送請求連接需求"+tmp);
out.write(tmp.getBytes());
new_message(IP, Integer.valueOf(send_port));
out.flush();
out.close();
out = null;
client.close();
client = null;
} catch (java.io.IOException e) {
System.out.println("Socket連線有問題 !");
System.out.println("IOException :" + e.toString());
}
}
}
}
view raw main.java hosted with ❤ by GitHub
package messager;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Frame;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.EmptyBorder;
import java.util.Date;
import java.text.SimpleDateFormat;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.DefaultListModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.BufferedOutputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.DropMode;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Font;
import java.awt.event.InputMethodListener;
import java.awt.event.InputMethodEvent;
public class msg extends JFrame {
public boolean start = false;
public SocketServer task;
public Thread t;// ����Thread����
public static String IP;
public static int send_port;
public String msg;
java.io.BufferedInputStream in;
private JPanel contentPane;
private JTextField textField;
public static DefaultListModel model = new DefaultListModel();
public static DefaultListModel model2 = new DefaultListModel();
public JList list = new JList(model);
public JTextPane textPane = new JTextPane();
public JScrollPane scrollPane = new JScrollPane();
public Frame src;
private final JButton btnNewButton_1 = new JButton("~");
/**
* Launch the application.
*/
/**
* Create the frame.
*/
public String getDateTime() {
SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
Date date = new Date();
String strDate = sdFormat.format(date);
// System.out.println(strDate);
return strDate;
}
public msg(String ip, int port) {
this.IP = ip;
this.send_port = port;
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent arg0) {
src.dispose();
}
@Override
public void windowOpened(WindowEvent e) {
src = (Frame) e.getSource();
}
});
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 482, 399);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
textField = new JTextField();
textField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER) {
new SocketClient( textField.getText());
textField.setText("");;
}
}
});
textField.setColumns(10);
JButton btnNewButton = new JButton("\u9001\u51FA");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new SocketClient( textField.getText());
}
});
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(textField, GroupLayout.PREFERRED_SIZE, 309, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btnNewButton_1, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(btnNewButton))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(2)
.addComponent(scrollPane)))
.addGap(496)
.addComponent(list, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(list, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 233, GroupLayout.PREFERRED_SIZE)
.addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup()
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(btnNewButton_1, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, 54, GroupLayout.PREFERRED_SIZE))
.addContainerGap())))
);
scrollPane.setViewportView(textPane);
textPane.setFont(new Font("Consolas", Font.PLAIN, 11));
textPane.setContentType("text/html");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new SocketClient( "shake");
}
});
contentPane.setLayout(gl_contentPane);
setVisible(true); // -->��� Frame2
start_server();
}
public void start_server() {
task = new SocketServer();
t = new Thread(task);
t.start(); // �}�l����t.run()
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
msg frame = new msg(IP, send_port);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public class SocketServer extends java.lang.Thread {
private boolean OutServer = false;
private ServerSocket server;
private int ServerPort = send_port;// �n�ʱ���port
public SocketServer() {
try {
server = new ServerSocket(ServerPort);
} catch (java.io.IOException e) {
System.out.println("Socket�Ұʦ����D !");
System.out.println("IOException :" + e.toString());
}
}
public void run() {
InputStreamReader inSR = null;
OutputStreamWriter outSW = null;
Socket socket;
java.io.BufferedInputStream in;
System.out.println("\n���A���w�Ұ� !");
System.out.println("IP:" + IP + " Port:" + send_port + "\n���A���w�]�w����");
while (!OutServer) {
socket = null;
try {
synchronized (server) {
socket = server.accept();
}
System.out.println("�����s�u : InetAddress = " + socket.getInetAddress());
//
socket.setSoTimeout(15000);
inSR = new InputStreamReader(socket.getInputStream(), "UTF-8");
BufferedReader br = new BufferedReader(inSR);
in = new java.io.BufferedInputStream(socket.getInputStream());
byte[] b = new byte[1024];
String data = "";
int length;
while ((length = in.read(b)) > 0)// <=0���ܴN�O�����F
{
data += new String(b, 0, length, "big5");
}
model.addElement("<" + IP + getDateTime() + "> :" + data);
get_msg();
System.out.println(IP + data);
in.close();
in = null;
socket.close();
} catch (java.io.IOException e) {
System.out.println("Socket�s�u�����D !");
System.out.println("IOException :" + e.toString());
}
}
}
}
public class SocketClient extends java.lang.Thread {
private String address = IP;// �s�u��ip
private int port = send_port;// �s�u��port
public SocketClient(String tmp) {
Socket client = new Socket();
InetSocketAddress isa = new InetSocketAddress(this.address, this.port);
try {
client.connect(isa, 10000);
BufferedOutputStream out = new BufferedOutputStream(client.getOutputStream());
// �e�X�r��
model.addElement("<" + "�ڻ�" + getDateTime() + "> :" + tmp);
get_msg();
out.write(tmp.getBytes());
out.flush();
out.close();
out = null;
client.close();
client = null;
} catch (java.io.IOException e) {
System.out.println(this.address);
System.out.println(this.port);
System.out.println("Socket�s�u�����D !");
System.out.println("IOException :" + e.toString());
}
}
}
public String get_msg() throws IOException {
String tmp = "<html><head>" + " <meta charset=" + '"' + "big-5" + '"' + " /></head>\n";
for (int i = 0; i < model.size(); i++) {
tmp += model.get(i).toString() + "<br>";
if (model.size() - 1 == i) {
if (model.get(i).toString().indexOf(":shake") != -1) {
shake();
}
}
}
tmp += "</body></html>";
String url = "file:///C:/test.gif";
tmp = (tmp.replace(":QQ", "<img src=" + url + "></img>"));
tmp = (tmp.replace(":shake", "</p><font color=" + '"' + "red" + '"' + ">�o�e�_��</font>"));
tmp += "/n";
System.out.print(tmp);
textPane.setText(tmp);
textPane.setCaretPosition(textPane.getDocument().getLength());
textPane.repaint();
return tmp;
}
public void shake() {
// TODO Auto-generated method stub
int or_x = this.location().x;
int or_y = this.location().y;
this.setLocation(or_x, or_y + 10);
try {
Thread.sleep(30);
this.setLocation(or_x + 20, or_y + 20);
Thread.sleep(30);
this.setLocation(or_x, or_y + 0);
Thread.sleep(30);
this.setLocation(or_x + 20, or_y + 0);
Thread.sleep(30);
this.setLocation(or_x, or_y + 20);
Thread.sleep(30);
this.setLocation(or_x, or_y + 0);
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.setLocation(or_x, or_y);
}
}
view raw msg.java hosted with ❤ by GitHub
package messager;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Image;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.event.AncestorListener;
import messager.msg.SocketClient;
import java.awt.Graphics;
import java.io.File;
import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.swing.event.AncestorEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Color;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class test extends JFrame {
private JPanel contentPane;
private JTextField txtX;
private JPasswordField passwordField;
public InetAddress myComputer = InetAddress.getLocalHost() ;
// linux �ƾڮw
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
test frame = new test();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
* @throws UnknownHostException
*
* @throws UnsupportedLookAndFeelException
* @throws IllegalAccessException
* @throws InstantiationException
* @throws ClassNotFoundException
*/
public test() throws UnknownHostException {
setResizable(false);
// UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
Frame src = (Frame) e.getSource();
src.dispose();
}
});
JButton btnNewButton = new JButton("\u767B\u5165");
JLabel lblNewLabel = new JLabel("\u5E33\u865F");
JLabel lblNewLabel_2 = new JLabel("");
JLabel lblNewLabel_1 = new JLabel("\u5BC6\u78BC");
JLabel lblNewLabel_3 = new JLabel("");
setTitle("Messager");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 241, 532);
contentPane = new JPanel();
contentPane.setBackground(new Color(255, 255, 255));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
this.setVisible(false);
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
login();
}
});
btnNewButton.setHorizontalAlignment(SwingConstants.TRAILING);
txtX = new JTextField();
txtX.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER) {
login();
txtX.setText("");;
}
}
});
txtX.setText("x213212");
txtX.setColumns(10);
passwordField = new JPasswordField();
passwordField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER) {
login();
passwordField.setText("");;
}
}
});
passwordField.setToolTipText("");
lblNewLabel_3.setVerticalAlignment(SwingConstants.BOTTOM);
lblNewLabel_3.addAncestorListener(new AncestorListener() {
public void ancestorAdded(AncestorEvent event) {
ImageIcon icon = new ImageIcon("src\\HOO.jpg");
lblNewLabel_3.setIcon(icon);
}
public void ancestorMoved(AncestorEvent event) {
}
public void ancestorRemoved(AncestorEvent event) {
}
});
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(lblNewLabel_3, GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE))
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblNewLabel)
.addGap(132))
.addComponent(lblNewLabel_1)
.addComponent(txtX, GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
.addComponent(passwordField, GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(29)
.addComponent(lblNewLabel_2))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(79)
.addComponent(btnNewButton)))
.addContainerGap())
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(lblNewLabel_3, GroupLayout.PREFERRED_SIZE, 185, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED, 81, Short.MAX_VALUE)
.addComponent(lblNewLabel)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(txtX, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(14)
.addComponent(lblNewLabel_1)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(passwordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(45)
.addComponent(lblNewLabel_2)
.addGap(22)
.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
contentPane.setLayout(gl_contentPane);
}
public void login()
{String mysqlback_id = null, mysqlback_pas = null;
try {
Class.forName("com.mysql.jdbc.Driver");
// ���Udriver
// linux �ƾڮw
Connection con = DriverManager.getConnection(
"jdbc:mysql://"+"192.168.153.130" +"/messager?useUnicode=true&characterEncoding=UTF8"
//"jdbc:mysql://192.168.153.130/messager?useUnicode=true&characterEncoding=UTF8"
, "root",
"x123456789");
// ���oconnection
Statement st = con.createStatement();
st.execute("SELECT * FROM user where id='" + txtX.getText() + "' &&" + " password='"
+ passwordField.getText() + "'");
ResultSet rs = st.getResultSet();
while (rs.next()) {
mysqlback_id = rs.getString("id");
mysqlback_pas = rs.getString("password");
}
if (mysqlback_id == null && mysqlback_pas == null) {
JOptionPane.showMessageDialog(null, "�b���αK�X���~�Э��s����!");
} else {
///myComputer.getHostAddress()
new main(mysqlback_id,mysqlback_pas,"192.168.153.130","192.168.153.1");
dispose();
con.close();
}
} catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(null, "�P���A�����o��ƥ���!");
System.out.println("DriverClassNotFound :" + e.toString());
} // ���i��|����sqlexception
catch (SQLException x) {
System.out.println("Exception :" + x.toString());
}
}
}
view raw test.java hosted with ❤ by GitHub

Face detection_抓小偷

介紹


如果java client 端如果有偵測到人臉的話會儲存一張圖片到c:\\peoples.png
然後偵測到的人臉大於1的話則會將嫌疑人的照片儲存下來並發送一張圖片到
指定ip並告知可能有人在你家
Server 端如果有將會一直開著持續監聽

環境設定


Eclipse
Android studio
Opencv 2.49 or 48


Javacv 1.2建置


下載好javacv後建立一個eclipse 專案 jse就可以了這邊要來做監控的client,記得把這些函示庫引入

Opencv 建置


64位元就選x64,32位元就選x86

Face detection.code



package com.example.jack.myapplication;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
ServerTcpListener Server=null;
TextView IPVIEW,conter_tx;
ScrollView sco1;
ImageView img1;
int conter;
Thread t;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//顯示你的ip這我拿來看手機連到wifi的ip才能指定socket 互傳檔案
IPVIEW=(TextView) findViewById(R.id.textView);
IPVIEW.setText( getMyIp() .toString());
//用在偵測到人要變換視窗顏色
conter_tx=(TextView)findViewById(R.id.textView2) ;
sco1=(ScrollView)findViewById(R.id.sco1) ;
//開啟一個thread去呼叫server並開啟
t = new Thread(new ServerTcpListener(this));
t.start();
img1=(ImageView)findViewById(R.id.imageView);
IPVIEW.setText( "server is start!!");
}
private String getMyIp(){
//新增一個WifiManager物件並取得WIFI_SERVICE
WifiManager wifi_service = (WifiManager)getSystemService(WIFI_SERVICE);
//取得wifi資訊
WifiInfo wifiInfo = wifi_service.getConnectionInfo();
//取得IP,但這會是一個詭異的數字,還要再自己換算才行
int ipAddress = wifiInfo.getIpAddress();
//利用位移運算和AND運算計算IP
String ip = String.format("%d.%d.%d.%d",(ipAddress & 0xff),(ipAddress >> 8 & 0xff),(ipAddress >> 16 & 0xff),(ipAddress >> 24 & 0xff));
return ip;
}
}
Android server : ServerTcpListener
package com.example.jack.myapplication;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
/**
* Created by JACK on 2016/12/8.
*/
public class ServerTcpListener implements Runnable {
public MainActivity tmp;
private static Context mContext;
public static void main(String[] args) {
}
public ServerTcpListener(MainActivity tmp)
{this.tmp=tmp;
mContext=tmp;
}
public void run() {
try {
final ServerSocket server = new ServerSocket(ClientTcpSend.port);
while (true) {
try {
System.out.println("監聽中...");
Socket socket = server.accept();
System.out.println("有資料傳送!");
receiveFile(socket);
} catch (Exception e) {
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void receiveFile(Socket socket) {
byte[] inputByte = null;
int length = 0;
DataInputStream dis = null;
FileOutputStream fos = null;
try {
try {
dis = new DataInputStream(socket.getInputStream());
fos = new FileOutputStream(new
////這邊要注意如果要取得內部sd卡位置
File( Environment.getExternalStorageDirectory().getAbsolutePath()+"//aa.png"));
inputByte = new byte[1024*4];
System.out.println("開始接收檔案...");
while ((length = dis.read(inputByte, 0, inputByte.length)) > 0) {
fos.write(inputByte, 0, length);
fos.flush();
}
System.out.println("完成接收");
Bitmap bMap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath()+"//aa.png");
///畫面即時更新ui
new Thread(new Runnable() {
public void run() {
//這邊是背景thread在運作, 這邊可以處理比較長時間或大量的運算
((Activity) mContext).runOnUiThread(new Runnable() {
public void run() {
//這邊是呼叫main thread handler幫我們處理UI部分
Bitmap bMap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath()+"//aa.png");
tmp.img1.setImageBitmap( bMap);
tmp.conter_tx.setText("可能被侵入次數:"+tmp.conter);
tmp.conter+=1;
}
});
}
}).start();
} finally {
if (fos != null)
fos.close();
if (dis != null)
dis.close();
if (socket != null)
socket.close();
}
} catch (Exception e) {
}
}
}
package test;
import javax.swing.*;
import java.awt.Toolkit;
import java.io.File;
import java.net.URL;
import org.bytedeco.javacpp.Loader;
import org.bytedeco.javacpp.opencv_core.IplImage;
import org.bytedeco.javacv.CanvasFrame;
import org.bytedeco.javacv.FrameGrabber;
import org.bytedeco.javacv.OpenCVFrameConverter;
import org.bytedeco.javacv.OpenCVFrameGrabber;
import static org.bytedeco.javacpp.opencv_core.*;
import static org.bytedeco.javacpp.opencv_imgproc.*;
import static org.bytedeco.javacpp.opencv_highgui.*;
import static org.bytedeco.javacpp.opencv_imgcodecs.*;
import static org.bytedeco.javacpp.helper.opencv_objdetect.cvHaarDetectObjects;
import org.bytedeco.javacpp.opencv_core.CvMemStorage;
import org.bytedeco.javacpp.opencv_core.CvRect;
import org.bytedeco.javacpp.opencv_core.CvScalar;
import org.bytedeco.javacpp.opencv_core.CvSeq;
import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_8U;
import static org.bytedeco.javacpp.opencv_core.cvClearMemStorage;
import static org.bytedeco.javacpp.opencv_core.cvGetSeqElem;
import static org.bytedeco.javacpp.opencv_core.cvLoad;
import static org.bytedeco.javacpp.opencv_core.cvPoint;
import static org.bytedeco.javacpp.opencv_imgproc.CV_BGR2GRAY;
import static org.bytedeco.javacpp.opencv_imgproc.cvCvtColor;
import org.bytedeco.javacpp.opencv_objdetect;
import static org.bytedeco.javacpp.opencv_objdetect.CV_HAAR_DO_CANNY_PRUNING;
import org.bytedeco.javacpp.opencv_objdetect.CvHaarClassifierCascade;
public class test {
static OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage();
public static void main(String args[]) {
System.out.println("ok");
//用 FrameGrabber 取得 得webcam
FrameGrabber grabber = new OpenCVFrameGrabber("");
//宣告一個CanvasFrame ,就把它當作是一個JFrame用。
CanvasFrame canvas = new CanvasFrame("Webcam", CanvasFrame.getDefaultGamma() / grabber.getGamma());
//設定這一個JFrame關閉時順便把程式結束。
canvas.setDefaultCloseOperation(
javax.swing.JFrame.EXIT_ON_CLOSE);
try {
//從網路上取得訓練好的檔案(不太建議用2.4版本的會有問題)
URL url = new URL("https://raw.github.com/Itseez/opencv/2.2/data/haarcascades/haarcascade_frontalface_alt.xml");
//把網頁上取回來的資料寫入本地端檔案
File file = Loader.extractResource(url, null, "classifier", ".xml");
//假如有相同檔名己存在則刪除舊友的
file.deleteOnExit();
//指定classifier檔案名稱(也就是剛才由網路上捉下來的檔案路徑)
String classifierName = file.getAbsolutePath();
// 預先載入 opencv_objdetect module .
Loader.load(opencv_objdetect.class);
//初始化HaarClassifierCascade
CvHaarClassifierCascade classifier = new CvHaarClassifierCascade(cvLoad(classifierName));
//假如載入HaarClassifierCascade 失敗則結束程式
if (classifier.isNull()) {
System.err.println("Error loading classifier file \"" + classifierName + "\".");
System.exit(1);
}
//啟動WebCam
grabber.start();
//定義一個IplImage 存放取出來的影像
IplImage img;
//先取一張畫面放入IplImage
img = converter.convert(grabber.grab());
//取得影像的長寬
int width = img.width();
int height = img.height();
//建立一個灰階影像(用IPL_DEPTH_8U 原因為,灰階影像每一個pixel R,G,B值皆相等,只需要存一份即可)
IplImage grayImage = IplImage.create(width, height, IPL_DEPTH_8U, 1);
//建立一個CvMemStorage做運算用
CvMemStorage storage = CvMemStorage.create();
//設定顯示用的CanvasFrame為取出的影像大小
canvas.setCanvasSize(grabber.getImageWidth(),
grabber.getImageHeight());
while (canvas.isVisible() && (img = converter.convert(grabber.grab())) != null) {
//重置運算用的CvMemStorage
cvClearMemStorage(storage);
// 把原始影像變成灰階
cvCvtColor(img, grayImage, CV_BGR2GRAY);
//偵測人臉
CvSeq faces = cvHaarDetectObjects(grayImage, classifier, storage,
1.1, 3, CV_HAAR_DO_CANNY_PRUNING);
//取得捉到的人臉
//檢測到底有沒有一個人臉以上有的話則發送到server端
int total = faces.total();
if(total>0)
{
cvSaveImage("/peoples.png",img);
new ClientTcpSend();
}
//在人臉上畫一個綠色的矩型
for (int i = 0; i < total; i++) {
CvRect r = new CvRect(cvGetSeqElem(faces, i));
int x = r.x(), y = r.y(), w = r.width(), h = r.height();
cvRectangle(img, cvPoint(x, y), cvPoint(x + w, y + h), CvScalar.GREEN, 1, CV_AA, 0);
}
//顯示圖片
cvShowImage( "Detection...", img );
cvWaitKey(200);
Toolkit toolkit = Toolkit.getDefaultToolkit();
toolkit.beep();
}
}
catch(Exception e)
{
}
}
}
//這邊的話可以看到 可以選擇要不要定時發出蜂鳴器 引起嫌犯人看鏡頭
Toolkit toolkit = Toolkit.getDefaultToolkit();
toolkit.beep();