SlideShare a Scribd company logo
1 of 26
「陽春版炸彈超人」遊戲 
心理四李紹銘
開始 
KeyEventArgs 
MonsterTimer啟動: 
1.怪物會移動 
2.怪物會傷人 
Move函式 
1.改變圖檔 
2.改變位置If true 
switch 
↑↓←→ 
F 
R K Esc 
開始 
PutBomb( 人物位置x,y) 
If true 
1.DrawBomb() 
2.啟動D2timer 
3秒後炸彈爆 
3.DrawAFire() 
4.clean() 
100 ms後火花消失 
GetPower() 
改變火花大小 
判別人 
死?() 
停止怪物動作 
If true 
怪物被 
燒傷?() 
令Stillfring = true 
令Stillfring = false 
停止使用鍵盤的移動& 放炸彈 
怪物被燒 
第二次()? 
怪物怒! 
If true 
If true
KeyEventArgs e 
• public void Form1_KeyDown(object sender, KeyEventArgs e)/*按鍵產生的事件 
*/ 
• { 
• if(PlayerAction) /* PlayerAction值按下”開始”時會令為true*/ 
• { 
• switch (e.KeyCode) 
• { 
• case Keys.Up: 
• { 
• MoveUp(); 
• break; 
• } 
• 
• } 
• } 
• } 
….
• case Keys.Up: ) /*上下左右見移動,呼叫移動的函式*/ 
• { 
• MoveUp(); 
• break; 
• } 
• case Keys.Down: 
• { 
• MoveDown(); 
• break; 
• } 
• case Keys.Left: 
• { 
• MoveLeft(); 
• break; 
• } 
• case Keys.Right: 
• { 
• MoveRight(); 
• break; 
• }
移動的函式 
• public void MoveUp() 
• { 
• if (UpGo && UpGo_g) /*布林值由死亡函式決定*/ 
• { 
• picS.Image = Image.FromFile("..pic_for_showman_up.png"); 
• picS.Location = new System.Drawing.Point(picS.Location.X, picS.Location.Y - 40); 
• } 
• } 
• public void MoveDown() 
• { 
• if (DownGo && DownGo_g) 
• { 
• picS.Location = new System.Drawing.Point(picS.Location.X, picS.Location.Y + 40); 
• picS.Image = Image.FromFile("..pic_for_showman_down.png"); 
• } 
• }
• public void MoveLeft() 
• { 
• LeftGo = (picS.Location.X > 100); 
• //之後要寫判別撞到wall rock bomb都不能移動的部分 
• if (LeftGo && LeftGo_g) 
• { 
• picS.Location = new System.Drawing.Point(picS.Location.X - 40, 
picS.Location.Y); 
• picS.Image = Image.FromFile("..pic_for_showman_left.png"); 
• } 
• }
• case Keys.F: /*放炸彈*/ 
• { 
• if (bomb_number < Quta) 
• { 
• Px[bomb_number] = picS.Location.X; 
• Py[bomb_number] = picS.Location.Y - 100; 
• PutBomb(Px[bomb_number], Py[bomb_number]); 
• } 
• break; 
• } 
• case Keys.Q: /*自殺鍵*/ 
• { 
• Dead(); 
• break; 
• } 
• case Keys.R: : /*復活鍵*/ 
• { 
• Revive(); 
• break; 
• }
• case Keys.Escape: : /*跳離程式*/ 
• { 
• Close(); 
• break; 
• } 
• 
• case Keys.K : /*重新招喚怪物*/ 
• { 
• MonsterDieTimer.Enabled = false; 
• MM.Visible = true; 
• MM.Image = Image.FromFile("..pic_for_showmonster.png"); 
• MonsterDead = false; 
• MonsterTimer.Enabled = true; 
• break; 
• }
死亡函式 
• public void Dead() 
• { 
• string fileName2; 
• fileName2 = "..pic_for_showdie.png"; 
• picS.Image = Image.FromFile(fileName2); 
• UpGo_g = false; 
• DownGo_g = false; 
• LeftGo_g = false; 
• RightGo_g = false; //死了不能移動 
• CanPutBomb = false; //死了不能放炸彈 
• }
判別是否被燒死函式 
• public void BurningToDead(int Loc_x, int Loc_y) 
• { 
• if (Stillfiring) //如果火還在燒 
• { 
• bool h1 = (Loc_x + picS.Size.Width > bomb_loc_X - firelength); 
• //火焰的左右手臂內 
• bool h2 = (Loc_x < bomb_loc_X + 100 + firelength); 
• bool h3 = (Loc_y < bomb_loc_Y + 100); 
• bool h4 = (Loc_y + picS.Size.Height > bomb_loc_Y); 
• bool v1 = (Loc_x + picS.Size.Width > bomb_loc_X); //火焰的上下手臂內 
• bool v2 = (Loc_x < bomb_loc_X + 100); 
• bool v3 = (Loc_y < bomb_loc_Y + 100 + firelength); 
• bool v4 = (Loc_y + picS.Size.Height > bomb_loc_Y - firelength); 
• if ((h1 && h2 && h3 && h4) | (v1 && v2 && v3 && v4)) 
• { Dead(); } 
• } 
• }
判別怪獸被燒死也同理 
• if ((h1 && h2 && h3 && h4) | (v1 && v2 && v3 && v4)) 
• { 
• MM.Image = Image.FromFile(“..pic_for_showmonster_die.png”); 
• //改成死掉的圖 
• MonsterDead = true; 
• MonsterHurt = false; 
• Dtimer2.Enabled = false; 
• MonsterDieTimer.Enabled = true; 
• RageLabel.Visible = false; 
• }
復活函式 
• public void Revive() 
• { 
• picS.Image = 
Image.FromFile("..pic_for_showman_down.png"); 
• UpGo_g = true; 
• DownGo_g = true; 
• LeftGo_g = true; 
• RightGo_g = true; //能移動 
• CanPutBomb = true; //能放炸彈 
• }
PutBomb函式 
• public void PutBomb(int bomb_loc_X,int bomb_loc_Y) 
• { 
• if (bomb_number < Quta && CanPutBomb) 
• { 
• DrawBomb( bomb_loc_X, bomb_loc_Y); 
• /*根據位置畫出炸彈位置*/ 
• B1timer.Enabled = true; 
• /*開始計時,3秒後爆炸*/ 
• } 
• }
設定Tick時會發生的事件 
每隔interval= 2000 毫秒就tick一次
B1timer_Tick() 
• private void B1timer_Tick(object sender, EventArgs e) 
• { 
• DrawAFire(Px[bomb_number], Py[bomb_number]); 
• /*畫出十字火花*/ 
• B1timer.Enabled = false; /*關掉計時器*/ 
• FireOverTimer.Enabled = true; 
• /*火花延遲時間計時器*/ 
• Stillfiring = true; /*火花延遲中*/ 
• bomb_number++; //累積下一個炸彈 
• }
DrawAFire函式 
• public void DrawAFire(int bomb_loc_X, int bomb_loc_Y) 
• { 
• this.bomb_loc_X = bomb_loc_X; 
• this.bomb_loc_Y = bomb_loc_Y; 
• graphics = CreateGraphics(); 
• image = Image.FromFile( "..pic_for_showyellow_c.png"); 
• graphics.DrawImage(image, bomb_loc_X, bomb_loc_Y, 100, 100);//火焰中央 
• image = Image.FromFile("..pic_for_showyellow_v.png"); 
• graphics.DrawImage(image, bomb_loc_X, bomb_loc_Y - firelength, 100, firelength); 
//火焰向上 
• graphics.DrawImage(image, bomb_loc_X, bomb_loc_Y + firelength, 100, firelength); 
//火焰向下 
• image = Image.FromFile("..pic_for_showyellow_h.png"); 
• graphics.DrawImage(image, bomb_loc_X - firelength, bomb_loc_Y, firelength, 100); 
//火焰向左 
• graphics.DrawImage(image, bomb_loc_X + 100, bomb_loc_Y, firelength, 100); 
• //火焰向右 
• }
• private void FireOverTimer_Tick(object sender, EventArgs e) 
• { 
• CleanFire(); /*洗掉畫面的火花*/ 
• FireOverTimer.Enabled = false; 
• Stillfiring = false; /*火花不延遲*/ 
• } 
• public void CleanFire() 
• { 
• Invalidate(); 
• }
MonsterTimer_Tick() 
• private void MonsterTimer_Tick(object sender, EventArgs e) 
• { 
• Random rand = new Random(); 
• int u; 
• int v; 
• u = (rand.Next() % 100) - 50; //怪獸隨機的亂跑移動-50~-100間的整數 
• v = (rand.Next() % 100) - 50; 
if (MM.Location.X + u > 0 && MM.Location.X + u + 100 < 900 && MM.Location.Y + v 
> 0 && M.Location.Y + v + 100 < 600 && !MonsterDead) 
//若沒碰到且怪獸還活著才移動 
• { 
• MM.Location = new System.Drawing.Point(MM.Location.X + u, 
MM.Location.Y + v); 
• }
MonsterTimer_Tick()續 
• MonsterBurningToHalfDead(MM.Location.X, 
MM.Location.Y); //判別是否被火焰燒到 
• if (MonsterHurt) //如果受傷才開啟新的timer 
• { 
• MonsterTimer.Enabled = false; 
• Dtimer2.Enabled = true; 
• } 
• }
Dtimer2_Tick() 
• private void Dtimer2_Tick(object sender, EventArgs e) 
• { 
• Random rand = new Random(); 
• int u; 
• int v; 
• u = (rand.Next() % 200) - 100; //數值變動變大,移動變劇 
• v = (rand.Next() % 200) - 100; 
• if (MM.Location.X + u > 0 && MM.Location.X + u + 100 < 900 && MM.Location.Y + v 
> 0 && MM.Location.Y + v + 100 < 600 && !MonsterDead) 
• { 
• MM.Location = new System.Drawing.Point(MM.Location.X + u, MM.Location.Y + v); 
• } 
• RageLabel.Location = new System.Drawing.Point(MM.Location.X + 20, 
MM.Location.Y - 80); 
• RageLabel.Visible = true; ; //顯示“ 怒!!!”的字樣 
• MonsterBurningToDead(MM.Location.X, MM.Location.Y); //判別是否被火焰燒死 
• } //開啟狂怒狀態!!
超人碰到怪獸死掉函式 
• public void TouchMonsterToDead(int Loc_x, int Loc_y) 
• { 
• bool a1 = (Loc_x + 100 > MM.Location.X); 
• bool a2 = (Loc_x < MM.Location.X + 100); 
• bool a3 = (Loc_y < MM.Location.Y + 100); 
• bool a4 = (Loc_y + 100 > MM.Location.Y); 
• if (!MonsterDead && a1 && a2 && a3 && a4) 
• { Dead(); } 
• } //只要怪獸活著都有效
怪獸死掉一陣子後屍體消失 
• private void MonsterDieTimer_Tick(object sender, EventArgs e) 
• { 
• MM.Visible = false; 
• MonsterDieTimer.Enabled = false; 
• }
增加火力裝備出現事件 
• private void PowerUpShowUpTimer_Tick(object sender, 
EventArgs e) 
• { 
• PowerUp.Visible = true; 
• CanGetPower=true; //變成看得到也吃得到 
• PowerUpShowUpTimer.Enabled = false; 
• }
GetPower函式 
• public void GetPower() 
• { 
• bool a1 = (picS.Location.X + 100 > PowerUp.Location.X); 
• bool a2 = (picS.Location.X < PowerUp.Location.X + 100); 
• bool a3 = (picS.Location.Y < PowerUp.Location.Y + 100); 
• bool a4 = (picS.Location.Y + 100 > PowerUp.Location.Y); 
• if (CanGetPower && a1 && a2 && a3 && a4) 
• //位置在裝備上面且允許吃裝備了 
• { 
• firelength = firelength + 50; 
• PowerUp.Visible = false; 
• CanGetPower = false; 
• } 
• }
MenulStrip上的選項 
• private void 結束EToolStripMenuItem_Click(object sender, EventArgs e) 
• { 
• Close(); 
• } 
• private void 說明ToolStripMenuItem_Click(object sender, EventArgs e) 
• { 
• MessageBox.Show( "歡迎來玩炸彈超人陽春板呀~n請按方向鍵移動 
n按F鍵放炸彈n按R鍵重生(密技~)n按K可以把死掉的怪物叫回來"); 
• } 
• 
• private void 開始SToolStripMenuItem_Click(object sender, EventArgs e) 
• { 
• MonsterTimer.Enabled = true; //怪獸開始動 
• PlayerAction = true; //允許玩家動作 
• PowerUpShowUpTimer.Enabled = true; 
• //開始倒數火力增加裝備出現時間 
• }
Thanks for your attention! 
暑假快樂!!

More Related Content

Featured

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

2010 C# final project: Bomberman

  • 2. 開始 KeyEventArgs MonsterTimer啟動: 1.怪物會移動 2.怪物會傷人 Move函式 1.改變圖檔 2.改變位置If true switch ↑↓←→ F R K Esc 開始 PutBomb( 人物位置x,y) If true 1.DrawBomb() 2.啟動D2timer 3秒後炸彈爆 3.DrawAFire() 4.clean() 100 ms後火花消失 GetPower() 改變火花大小 判別人 死?() 停止怪物動作 If true 怪物被 燒傷?() 令Stillfring = true 令Stillfring = false 停止使用鍵盤的移動& 放炸彈 怪物被燒 第二次()? 怪物怒! If true If true
  • 3. KeyEventArgs e • public void Form1_KeyDown(object sender, KeyEventArgs e)/*按鍵產生的事件 */ • { • if(PlayerAction) /* PlayerAction值按下”開始”時會令為true*/ • { • switch (e.KeyCode) • { • case Keys.Up: • { • MoveUp(); • break; • } • • } • } • } ….
  • 4. • case Keys.Up: ) /*上下左右見移動,呼叫移動的函式*/ • { • MoveUp(); • break; • } • case Keys.Down: • { • MoveDown(); • break; • } • case Keys.Left: • { • MoveLeft(); • break; • } • case Keys.Right: • { • MoveRight(); • break; • }
  • 5. 移動的函式 • public void MoveUp() • { • if (UpGo && UpGo_g) /*布林值由死亡函式決定*/ • { • picS.Image = Image.FromFile("..pic_for_showman_up.png"); • picS.Location = new System.Drawing.Point(picS.Location.X, picS.Location.Y - 40); • } • } • public void MoveDown() • { • if (DownGo && DownGo_g) • { • picS.Location = new System.Drawing.Point(picS.Location.X, picS.Location.Y + 40); • picS.Image = Image.FromFile("..pic_for_showman_down.png"); • } • }
  • 6. • public void MoveLeft() • { • LeftGo = (picS.Location.X > 100); • //之後要寫判別撞到wall rock bomb都不能移動的部分 • if (LeftGo && LeftGo_g) • { • picS.Location = new System.Drawing.Point(picS.Location.X - 40, picS.Location.Y); • picS.Image = Image.FromFile("..pic_for_showman_left.png"); • } • }
  • 7. • case Keys.F: /*放炸彈*/ • { • if (bomb_number < Quta) • { • Px[bomb_number] = picS.Location.X; • Py[bomb_number] = picS.Location.Y - 100; • PutBomb(Px[bomb_number], Py[bomb_number]); • } • break; • } • case Keys.Q: /*自殺鍵*/ • { • Dead(); • break; • } • case Keys.R: : /*復活鍵*/ • { • Revive(); • break; • }
  • 8. • case Keys.Escape: : /*跳離程式*/ • { • Close(); • break; • } • • case Keys.K : /*重新招喚怪物*/ • { • MonsterDieTimer.Enabled = false; • MM.Visible = true; • MM.Image = Image.FromFile("..pic_for_showmonster.png"); • MonsterDead = false; • MonsterTimer.Enabled = true; • break; • }
  • 9. 死亡函式 • public void Dead() • { • string fileName2; • fileName2 = "..pic_for_showdie.png"; • picS.Image = Image.FromFile(fileName2); • UpGo_g = false; • DownGo_g = false; • LeftGo_g = false; • RightGo_g = false; //死了不能移動 • CanPutBomb = false; //死了不能放炸彈 • }
  • 10. 判別是否被燒死函式 • public void BurningToDead(int Loc_x, int Loc_y) • { • if (Stillfiring) //如果火還在燒 • { • bool h1 = (Loc_x + picS.Size.Width > bomb_loc_X - firelength); • //火焰的左右手臂內 • bool h2 = (Loc_x < bomb_loc_X + 100 + firelength); • bool h3 = (Loc_y < bomb_loc_Y + 100); • bool h4 = (Loc_y + picS.Size.Height > bomb_loc_Y); • bool v1 = (Loc_x + picS.Size.Width > bomb_loc_X); //火焰的上下手臂內 • bool v2 = (Loc_x < bomb_loc_X + 100); • bool v3 = (Loc_y < bomb_loc_Y + 100 + firelength); • bool v4 = (Loc_y + picS.Size.Height > bomb_loc_Y - firelength); • if ((h1 && h2 && h3 && h4) | (v1 && v2 && v3 && v4)) • { Dead(); } • } • }
  • 11. 判別怪獸被燒死也同理 • if ((h1 && h2 && h3 && h4) | (v1 && v2 && v3 && v4)) • { • MM.Image = Image.FromFile(“..pic_for_showmonster_die.png”); • //改成死掉的圖 • MonsterDead = true; • MonsterHurt = false; • Dtimer2.Enabled = false; • MonsterDieTimer.Enabled = true; • RageLabel.Visible = false; • }
  • 12. 復活函式 • public void Revive() • { • picS.Image = Image.FromFile("..pic_for_showman_down.png"); • UpGo_g = true; • DownGo_g = true; • LeftGo_g = true; • RightGo_g = true; //能移動 • CanPutBomb = true; //能放炸彈 • }
  • 13. PutBomb函式 • public void PutBomb(int bomb_loc_X,int bomb_loc_Y) • { • if (bomb_number < Quta && CanPutBomb) • { • DrawBomb( bomb_loc_X, bomb_loc_Y); • /*根據位置畫出炸彈位置*/ • B1timer.Enabled = true; • /*開始計時,3秒後爆炸*/ • } • }
  • 15. B1timer_Tick() • private void B1timer_Tick(object sender, EventArgs e) • { • DrawAFire(Px[bomb_number], Py[bomb_number]); • /*畫出十字火花*/ • B1timer.Enabled = false; /*關掉計時器*/ • FireOverTimer.Enabled = true; • /*火花延遲時間計時器*/ • Stillfiring = true; /*火花延遲中*/ • bomb_number++; //累積下一個炸彈 • }
  • 16. DrawAFire函式 • public void DrawAFire(int bomb_loc_X, int bomb_loc_Y) • { • this.bomb_loc_X = bomb_loc_X; • this.bomb_loc_Y = bomb_loc_Y; • graphics = CreateGraphics(); • image = Image.FromFile( "..pic_for_showyellow_c.png"); • graphics.DrawImage(image, bomb_loc_X, bomb_loc_Y, 100, 100);//火焰中央 • image = Image.FromFile("..pic_for_showyellow_v.png"); • graphics.DrawImage(image, bomb_loc_X, bomb_loc_Y - firelength, 100, firelength); //火焰向上 • graphics.DrawImage(image, bomb_loc_X, bomb_loc_Y + firelength, 100, firelength); //火焰向下 • image = Image.FromFile("..pic_for_showyellow_h.png"); • graphics.DrawImage(image, bomb_loc_X - firelength, bomb_loc_Y, firelength, 100); //火焰向左 • graphics.DrawImage(image, bomb_loc_X + 100, bomb_loc_Y, firelength, 100); • //火焰向右 • }
  • 17. • private void FireOverTimer_Tick(object sender, EventArgs e) • { • CleanFire(); /*洗掉畫面的火花*/ • FireOverTimer.Enabled = false; • Stillfiring = false; /*火花不延遲*/ • } • public void CleanFire() • { • Invalidate(); • }
  • 18. MonsterTimer_Tick() • private void MonsterTimer_Tick(object sender, EventArgs e) • { • Random rand = new Random(); • int u; • int v; • u = (rand.Next() % 100) - 50; //怪獸隨機的亂跑移動-50~-100間的整數 • v = (rand.Next() % 100) - 50; if (MM.Location.X + u > 0 && MM.Location.X + u + 100 < 900 && MM.Location.Y + v > 0 && M.Location.Y + v + 100 < 600 && !MonsterDead) //若沒碰到且怪獸還活著才移動 • { • MM.Location = new System.Drawing.Point(MM.Location.X + u, MM.Location.Y + v); • }
  • 19. MonsterTimer_Tick()續 • MonsterBurningToHalfDead(MM.Location.X, MM.Location.Y); //判別是否被火焰燒到 • if (MonsterHurt) //如果受傷才開啟新的timer • { • MonsterTimer.Enabled = false; • Dtimer2.Enabled = true; • } • }
  • 20. Dtimer2_Tick() • private void Dtimer2_Tick(object sender, EventArgs e) • { • Random rand = new Random(); • int u; • int v; • u = (rand.Next() % 200) - 100; //數值變動變大,移動變劇 • v = (rand.Next() % 200) - 100; • if (MM.Location.X + u > 0 && MM.Location.X + u + 100 < 900 && MM.Location.Y + v > 0 && MM.Location.Y + v + 100 < 600 && !MonsterDead) • { • MM.Location = new System.Drawing.Point(MM.Location.X + u, MM.Location.Y + v); • } • RageLabel.Location = new System.Drawing.Point(MM.Location.X + 20, MM.Location.Y - 80); • RageLabel.Visible = true; ; //顯示“ 怒!!!”的字樣 • MonsterBurningToDead(MM.Location.X, MM.Location.Y); //判別是否被火焰燒死 • } //開啟狂怒狀態!!
  • 21. 超人碰到怪獸死掉函式 • public void TouchMonsterToDead(int Loc_x, int Loc_y) • { • bool a1 = (Loc_x + 100 > MM.Location.X); • bool a2 = (Loc_x < MM.Location.X + 100); • bool a3 = (Loc_y < MM.Location.Y + 100); • bool a4 = (Loc_y + 100 > MM.Location.Y); • if (!MonsterDead && a1 && a2 && a3 && a4) • { Dead(); } • } //只要怪獸活著都有效
  • 22. 怪獸死掉一陣子後屍體消失 • private void MonsterDieTimer_Tick(object sender, EventArgs e) • { • MM.Visible = false; • MonsterDieTimer.Enabled = false; • }
  • 23. 增加火力裝備出現事件 • private void PowerUpShowUpTimer_Tick(object sender, EventArgs e) • { • PowerUp.Visible = true; • CanGetPower=true; //變成看得到也吃得到 • PowerUpShowUpTimer.Enabled = false; • }
  • 24. GetPower函式 • public void GetPower() • { • bool a1 = (picS.Location.X + 100 > PowerUp.Location.X); • bool a2 = (picS.Location.X < PowerUp.Location.X + 100); • bool a3 = (picS.Location.Y < PowerUp.Location.Y + 100); • bool a4 = (picS.Location.Y + 100 > PowerUp.Location.Y); • if (CanGetPower && a1 && a2 && a3 && a4) • //位置在裝備上面且允許吃裝備了 • { • firelength = firelength + 50; • PowerUp.Visible = false; • CanGetPower = false; • } • }
  • 25. MenulStrip上的選項 • private void 結束EToolStripMenuItem_Click(object sender, EventArgs e) • { • Close(); • } • private void 說明ToolStripMenuItem_Click(object sender, EventArgs e) • { • MessageBox.Show( "歡迎來玩炸彈超人陽春板呀~n請按方向鍵移動 n按F鍵放炸彈n按R鍵重生(密技~)n按K可以把死掉的怪物叫回來"); • } • • private void 開始SToolStripMenuItem_Click(object sender, EventArgs e) • { • MonsterTimer.Enabled = true; //怪獸開始動 • PlayerAction = true; //允許玩家動作 • PowerUpShowUpTimer.Enabled = true; • //開始倒數火力增加裝備出現時間 • }
  • 26. Thanks for your attention! 暑假快樂!!