TRƯỜNG ĐẠI HỌC XÂY DỰNG
KHOA CNTT – BỘ MÔN CÔNG NGHỆ PHẦN MỀM ĐỒ ÁN: ĐỒ HỌA MÁY TÍNH 2 GIÁO VIÊN: PHAN THÁI TRUNG
SINH VIÊN: NGUYỄN HỒNG GIANG
MS: 4228.51
LỚP 51PM1
HÀ NỘI, 11/2009
Đồ Án Đồ Họa 2 2009
3
Nguyễn Hồng Giang – 4228.51 – Lớp 51PM1 http://www.ebook.edu.vn
Mục Lục
Mở Đầu 3
Quy trình thực hiện 4
Bước 1. Thay nhân vật. 4
Bước 1
Nhân v
Lập trìn
onClip
j
/
s
h
/
s
s
h
s
/
s
X
Ym
i
}
onCli
p
i
Xpos = th
Ypos = th
maxmove =
ispaused
root.ma
x
pEvent (e
if (Key.i
if(} e}
}
if ( root
if }
Hồng Gian
ực hiện
hân vật.
atform có s
ân vật:
oad) {
= false;
ng is tru
ue
health. x
o the sta
core. x;
core. y;
health. y
x;
the star
y;
me = 60;
e) {
12) || Ke
==true) {
pause =
sed = fal
pause
sed = tru
==false)
> Stage
.
health.t
51 – Lớp 5
hay bằng m
;
rting X
p
;
ting X p
o
C
Đồ Án Đồ Họa 2 2009
5
Nguyễn Hồng Giang – 4228.51 – Lớp 51PM1 http://www.ebook.edu.vn
if (_root.health.text == 0)
{
_root.dead=true;
}
_x = Xpos-_root._x;
//sets the X pos to the starting X postition of this MC
_root.score._x = scoreX-_root._x;
_root.score._y = scoreY-_root._y;
_root.sky._x = skyX - _root._x;
_root.sky._y = skyY - _root._y;
//sets the scire MCs X pos to its starting point on the
screen
_root.health._x = healthX-_root._x;
_root.health._y = healthY-_root._y;
//sets the health MCs X pos to its starting point on the
screen
if (!_root.ground.hitTest(this._x, this._y, true) &&
!jumping) {
// if NOT hitting X and Y postion with the ground and
NOT jumping
this._y += 6;
// Y positon moves up 6
}
_global.tongdiem = _root.score.text;
// moves the _root
_root.tree._x += 0.7*speed;
}
Đồ Án Đồ Họa 2 2009
6
Nguyễn Hồng Giang – 4228.51 – Lớp 51PM1 http://www.ebook.edu.vn
if (speed>0) {
//if speed is smaller than 0
dir = "right";
// the variable dir is set to right
} else if (speed<0) {
//if speed is greater than 0
dir = "left";
// the var dir is set to left
}
if (dir == "left" && !_root.cotmoc.hitTest(this._x-20,
this._y, true)) {
_root.health._x += speed;
_root.score._x += speed;
this._x += speed;
_root._x -= speed;
_root.tree._x += 0.7*speed;
}
if (Key.isDown(Key.LEFT)) {
// if left is pressed
if (speed>-maxmove) {
// if the speed is greater than neg.
maxmove
// _root.shooting is set true
with (_root.bulleter) {
// all code below this code and it's
closer refer to _root.bulleter
Đồ Án Đồ Họa 2 2009
7
Nguyễn Hồng Giang – 4228.51 – Lớp 51PM1 http://www.ebook.edu.vn
onEnterFrame = function () {
if
(_root.timer>_root.maxshoottime) {
// if _root.timer is
smaller than _root.maxshoottime
_root.shooting = false;
// shooting is false
unloadMovie(this);
// this movie clip is
unloaded
}
_root.timer+=5;
// _root.timer goes up 1
_x += _root.mvsp*5;
// the X goes up _root.mvsp
(which is set constantly and stays the same when shooting.)
};
};
}
attacking = true;
// attacking is true
}
if (jump<-15) {
// if jump is smaller than neg. 5
jump = -15;
// jump is set to neg 5
Đồ Án Đồ Họa 2 2009
8
Nguyễn Hồng Giang – 4228.51 – Lớp 51PM1 http://www.ebook.edu.vn
// capping fall speeds prevents falling
through grounds
}
}
if (_root.ground.hitTest(this._x, this._y, true) &&
falling) {
// if hitting X an Y postions with the ground and
falling
jump = 12;
// jump is set to 9
jumping = false;
// jumping is false
falling = false;
gotoAndStop("idle");
// falling is false
}
}
}
}
onClipEvent (keyUp) {
2009
ok.edu.vn10
Cột m
ố
Đặt tên
không đ
if (di
{
t}
Thanh n
bờ bên
0
Nguyễn
ốc ngăn khô
n cho movie
đi được nữ
ir == "le
root.he
51 – Lớp 5
dụng khóa
hi nhân vật
tmoc.hitT
d;
giúp nhân v
Đồ
51PM1
a lại map.
chạm vào
Test(this
vật có thể n
Án Đồ H
http://
tức là hitT
. x-20, t
nhảy từ bên
Họa 2
/www.eboo
Test thì nhân
this. y,
n bờ bên nà
2009
ok.edu.vn
n vật sẽ
true))
ày sang
i
}
Bước 3
Enemy
Loại 1
:
Loại 2
:
1
Nguyễn
ân vật khi đ
n vật. Nếu h
pEvent(lo
dir = "up
upstep =
downstep
pEvent(en
if(dir=="
ups
thi
if
char. y
s. y +=
-
(this.hit
+= -2;
"down") {
nstep++;
s. y +=
2
(this.hit
+= 2;
p == -100
tep = 0;
= "down
tep == 10
nstep = 0
= "up";
à thêm En
phát là chết
khởi tạo cho
ng – 4228.5
hanh ngang
di chuyển
) {
-2;
tTest( ro
2;
tTest( ro
0) {
";
n đạn mất
2009
ok.edu.vn
hính nó 2 máu.
12
onClip
e
e
e
e
d
m
}
onCli
p
i
i
i
Nguyễn
pEvent (l
enemyspee
enemystep
enemystep
enemydir
dead = fa
mau = 50;
pEvent (e
if (Key.i
ro
if
}
if (Key.i
if (! roo
if
}
if }
if
isDown(11
ot. pause
(this.hit
mau -
=
(this.hi
t
mau -
=
(mau<=0)
enemy
s
enemys
enemys
dead =
this.g
(this.hit
// if
root.
// ch
a
// roo
while(
}
// ro
o
ot.dead =
root.he
root.he
a
ot.health
oot.dead
{
NOT dead
nemydir =
51 – Lớp 5
y.isDown
;
char.goto
y.isDown
oot.char.
oot.bulle
;
t = 0;
= 0;
op("dead"
oot.char)
s the ch
a
ping = fa
jumping s
true;
alth.tex
t
alth.text
.text =
Họa 2
/www.eboo
se = fals
ot dead
e
2009
ok.edu.vn
e;
Đồ Án Đồ Họa 2 2009
13
Nguyễn Hồng Giang – 4228.51 – Lớp 51PM1 http://www.ebook.edu.vn
enemystepsright += 1;
this._xscale = -100;
this._x += enemyspeed;
} else if (enemydir == "left") {
enemystepsleft += 1;
this._xscale = 100;
this._x -= enemyspeed;
}
if (enemystepsright == 100) {
enemystepsright = 0;
enemydir = "left";
} else if (enemystepsleft == 100) {
enemystepsleft = 0;
// enemystepsleft is set to 0
enemydir = "right";
}
}
mau = 100
4. Lưu điể
ểm là một k
g PHP & M
Hồng Gian
giống loại
oad) {
ed = 2;
psright =
psleft =
= "left"
alse;
0;
ểm.
khâu cũng
MySQL hoặ
ng – 4228.5
2 nhưng có
= 0;
0;
";
rất cần thiế
ặc PHP lưu
51 – Lớp 5
ó 100 máu.
ết với các g
u vào file tx
Đồ
51PM1
ể
Khi bạn
lưu lại.
on(rel
i
5
Nguyễn
ột movie cl
ặt tên NAM
me high sc
Table.fil
Table.sco
Table.vie
Table.loa
om/scores
ode trên ch
scores.txt th
ểm khi bạn
n là người c
lease) {
if(! glob
sco
sco
sco
sco
Hồng Gian
ua (chiến th
g, nhập tên
{
filename
scoresize
action =
winname =
51 – Lớp 5
ác dynamic
ORE0-SCO
e sau:
t";
://nguyen
m là scores.t
php
hắng) gam
n vào ô dyn
= "score
e = 10;
"INSERT"
= root.t
Đồ
51PM1
c text. Các
ORE9.
nhonggian
txt, kích thư
e.
namic text v
es.txt";
Lưu điể
Cũng tư
và tên s
scores.t
Bước 5
Thanh l
chờ đợi
không b
biến đi
6
Nguyễn
sco
sco
om/scores
gl
}
ểm khi bạn
ương tự nh
sẽ được gử
txt
5. Preload
loader biểu
i. Nếu gam
biết game h
sự nghi ng
Hồng Gian
reTable.w
reTable.l
51PM1
al.tongdi
ttp://nguy
vào ô dynam
này sẽ làm
m cho ngườ
đối nặng, m
ay không. L
Án Đồ H
http://
em;
yenhonggi
mic text, nh
m nhiệm vụ
ời dùng cảm
mạng chậm
Lúc đó pre-
Họa 2
/www.eboo
iang.it-
hấn save th
ụ lưu điểm v
m thấy thoả
người dùn
g
-loader sẽ l
2009
ok.edu.vn
hì điểm
Khi pau
Ta khai
if (Kei
7
Nguyễn
pEvent(lo
this.prel
this.text
root.sto
pEvent(en
var loade
var total
var perce
this.prel
this.text
if (loade
ro
got
}
7. Pause /
use, ta dừn
i báo một b
ey.isDown
root. pa
if (jumpi
Hồng Gian
oad) {
("game",
e.
nh động củ
pause
Key.isDo
rue;
ot.char.g
51 – Lớp 5
= 1;
+ "%";
esLoaded
sTotal()
tal;
= Math.
r
th.round
1);
ủa nhân vật
own(80))
otoAndSt
o
Đồ
51PM1
();
;
round(100
(percent
t, enemy .
{
op("idle"
ỉ: http://ngu
Hồng Gian
n(111) ||
hoặc P : pa
c O: un pau
n
uyenhongg
ng – 4228.5
Key.isDo
ause,
use.
giang.it-uce
51 – Lớp 5
own(79))
e.com
-THE END
Đồ
51PM1
root. p
D
Án Đồ H
http://
ause = fa
Họa 2
/www.eboo
alse;
2009
ok.edu.vn