Unit 15A 類別定義與動畫(5%~10%)
1.
點按滑鼠,在滑鼠點按位置(圓中心)畫圓(3%)
2.
產生連續爆炸圖(3%)
3.
產生爆炸圖兩次(2%)
4.
點按滑鼠,在滑鼠點按位置產生爆炸圖兩次(3%)
5.
兩物體碰撞後產生爆炸圖(3%)
6.
顯示影像
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;
namespace 爆炸01
{
public
partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
Image
im = Properties.Resources.fire;
int
x, y; //滑鼠點按位置
Random
rd = new Random();
int
w, h; //小圖寬高
//宣告放小圖的二維陣列
Rectangle[,]
re = new Rectangle[3,
5];
int
r = 0, c = 0; //小圖陣列註標位置
private
void Form1_Load(object
sender, EventArgs e)
{
this.Width
= 960; this.Height = 640;
this.DesktopLocation
= new Point(8,
8);
w = im.Width / 5; h =
im.Height / 3;
//切割影像放在二維矩形
for
(int i= 0;i<3;i++)
for (int j = 0; j
< 5; j++)
re[i, j] = new Rectangle(j *
w, i * h, w, h);
}
private
void Form1_Paint(object
sender, PaintEventArgs e)
{
this.DoubleBuffered
= true;
e.Graphics.DrawImage(im,
300, 200, re[r,c],
GraphicsUnit.Pixel);
}
}
}
沒有留言:
張貼留言