Ciao !
Vi invio codice in DbPro ( non mio ..)
(link :
http://forum.thegamecreators.com/?m=foru...174784&b=6)
Codice:
[Spoiler]sync rate 60 : sync on
color backdrop 0 : autocam off
type tpac
move
x
y
z
edge
endtype
type tghost
move
x
y
z
angle
endtype
type tgate
time
flag
id
endtype
dim ghost(5) as tghost
dim old(5) as tghost
global pac as tpac
global old as tpac
global gate as tgate
global dots
CreatePacMan()
CreateGhost()
CreateGateAnim()
CreateLevel()
PlayMusic()
repeat
old.move = pac.move
old.x = pac.x
old.z = pac.z
if pac.x mod 32 = 0 and pac.z mod 32 = 0
if upkey() then pac.move = 1
if downkey() then pac.move = 2
if leftkey() then pac.move = 3
if rightkey() then pac.move = 4
endif
if pac.move = 1
pac.z = pac.z - 2
yrotate object 1, 0
endif
if pac.move = 2
pac.z = pac.z + 2
yrotate object 1, 180
endif
if pac.move = 3
pac.x = pac.x + 2
yrotate object 1, 270
endif
if pac.move = 4
pac.x = pac.x - 2
yrotate object 1, 90
endif
position object 1, pac.x, pac.y, pac.z
c = object collision(1, 0)
if c > 0 and c < 10 then exit
if c > 1000 and c < 2000 then inc score : delete object c
if c > 2000
pac.move = old.move
pac.x = old.x
pac.z = old.z
position object 1, pac.x, pac.y, pac.z
endif
set camera to follow pac.x, pac.y, pac.z, 180, 125, 300, 25, 0
point camera pac.x, pac.y, pac.z
for i = 1 to 5
old(i).move = ghost(i).move
old(i).x = ghost(i).x
old(i).z = ghost(i).z
old(i).angle = object angle y(1 + i)
if ghost(i).x mod 32 = 0 and ghost(i).z mod 32 = 0
do
ghost(i).move = rnd(3) + 1
if ghost(i).move = 1 and old(i).move <> 2 then exit
if ghost(i).move = 2 and old(i).move <> 1 then exit
if ghost(i).move = 3 and old(i).move <> 4 then exit
if ghost(i).move = 4 and old(i).move <> 3 then exit
loop
endif
if ghost(i).move = 1
ghost(i).z = ghost(i).z - 2
yrotate object 1 + i, 0
endif
if ghost(i).move = 2
ghost(i).z = ghost(i).z + 2
yrotate object 1 + i, 180
endif
if ghost(i).move = 3
ghost(i).x = ghost(i).x + 2
yrotate object 1 + i, 270
endif
if ghost(i).move = 4
ghost(i).x = ghost(i).x - 2
yrotate object 1 + i, 90
endif
position object 1 + i, ghost(i).x, ghost(i).y, ghost(i).z
c = object collision(1 + i, 0)
if c > 2000
ghost(i).move = old(i).move
ghost(i).x = old(i).x
ghost(i).z = old(i).z
yrotate object 1 + i, old(i).angle
position object 1 + i, ghost(i).x, ghost(i).y, ghost(i).z
endif
next i
AnimateGate(a)
AnimatePacMan(a)
AnimateGhost(a)
inc a
set cursor 0, 0
print "FPS:", screen fps()
print "Dots: ", score, "/", dots
sync
until score = dots
repeat : until mouseclick()
end
function CreatePacMan()
create bitmap 1, 64, 64
cls
ink rgb(255, 255, 0), 0
box 0, 0, 64, 32
ink -1, 0
text 16, 14, " OO "
text 16, 15, " OO "
ink 0, 0
text 16, 16, " '' "
text 16, 19, " '' "
get image 1, 0, 0, 64, 64
cls
ink rgb(255, 255, 0), 0
box 0, 32, 64, 64
get image 2, 0, 0, 64, 64
cls
ink rgb(255, 0, 0), 0
box 0, 32, 64, 64
get image 3, 0, 0, 64, 64
make object sphere 1, 30, 32, 32
make object sphere 2, 30, 32, 2
make mesh from object 1, 1
make mesh from object 2, 2
add limb 1, 1, 1
add limb 1, 2, 2
link limb 1, 1, 2
rotate limb 1, 2, 90, 0, 90
delete mesh 1
delete mesh 2
delete object 2
texture limb 1, 0, 1
texture limb 1, 1, 2
texture limb 1, 2, 3
set object transparency 1, 1
set object filter 1, 0
set object collision to boxes 1
delete bitmap 1
endfunction
function CreateGhost()
restore Color
for i = 2 to 6
create bitmap 1, 64, 64
read r, g, b
cls
ink rgb(r, g, b), 0
box 0, 0, 64, 64
ink -1, 0
text 16, 14, " OO "
text 16, 15, " OO "
ink 0, 0
text 16, 16, " '' "
text 16, 19, " '' "
get image 100 + i, 0, 0, 64, 64
cls
ink rgb(r, g, b), 255
box 0, 32, 64, 64
ink 0, 255
text 0, 49, "||||||||"
text 2, 49, "||||||||"
get image 200 + i, 0, 0, 64, 64
make object sphere i, 31, 32, 32
make object cylinder i + 1, 31
make mesh from object 1, i + 1
add limb i, 1, 1
delete mesh 1
delete object i + 1
texture limb i, 0, 100 + i
texture limb i, 1, 200 + i
set object transparency i, 1
set object filter i, 0
set object collision to polygons i
delete bitmap 1
next i
Color:
data 255, 0, 0
data 255, 128, 64
data 0, 255, 255
data 255, 0, 255
data 0, 0, 255
endfunction
function AnimatePacMan(a)
if pac.x > pac.edge then pac.x = 0
if pac.x < 0 then pac.x = pac.edge
rotate limb 1, 0, 20 + sin(a * 8) * 20, 0, 0
rotate limb 1, 1, -20 - sin(a * 8) * 20, 0, 0
endfunction
function AnimateGhost(a)
for i = 1 to 5
if ghost(i).x > pac.edge then ghost(i).x = 0
if ghost(i).x < 0 then ghost(i).x = pac.edge
rotate limb i + 1, 1, 0, sin(a * 8) * 50, 0
next i
endfunction
function AnimateGate(a)
if timer() > gate.time
gate.flag = abs(gate.flag - 1)
gate.time = timer() + 5000
if gate.flag
for i = 1 to gate.id
set object collision on 3000 + i
show object 3000 + i
next i
else
for i = 1 to gate.id
set object collision off 3000 + i
hide object 3000 + i
next i
endif
endif
for i = 1 to gate.id
texture object 3000 + i, 3000 + (a and 15)
next i
endfunction
function CreateGateAnim()
create bitmap 1, 64, 64
ink rgb(255, 255, 255), 0
for i = 0 to 15
cls
y2 = 16 + rnd(32)
for x1 = 0 to 64 step 4
x2 = x1 + 4
y1 = y2
y2 = 16 + rnd(32)
line x1, y1, x2, y2
next x1
get image 3000 + i, 0, 0, 64, 64
next i
delete bitmap 1
endfunction
function CreateLevel()
make object box 10, 32, 16, 32
make object cylinder 11, 8
make mesh from object 1, 11
add limb 10, 1, 1
add limb 10, 2, 1
add limb 10, 3, 1
add limb 10, 4, 1
offset limb 10, 1, 8, 6, 8
offset limb 10, 2, -8, 6, 8
offset limb 10, 3, 8, 6, -8
offset limb 10, 4, -8, 6, -8
make mesh from object 1, 10
delete object 10
delete object 11
restore Level
o1 = 1000
o2 = 2000
o3 = 3000
do
read l$
if l$ = "EOL" then exit
for lx = 1 to len(l$)
c$ = mid$(l$, lx)
if c$ = "." or c$ = "o"
inc dots
inc o1
if c$ = "."
make object sphere o1, 6
else
make object sphere o1, 14
endif
position object o1, (lx - 1) * 32, 0, lz * 32
color object o1, rgb(255, 128, 128)
endif
if c$ = "#"
inc o2
make object o2, 1, 0
position object o2, (lx - 1) * 32, 0, lz * 32
color object o2, 255
endif
if c$ = "c"
pac.x = (lx - 1) * 32
pac.y = 8
pac.z = lz * 32
endif
if c$ = "-"
inc gate.id
inc o3
make object plain o3, 32, 32
position object o3, (lx - 1) * 32, 8, lz * 32
xrotate object o3, 90
set object light o3, 0
ghost object on o3
endif
if c$ = "1"
ghost(1).x = (lx - 1) * 32
ghost(1).y = 8
ghost(1).z = lz * 32
endif
if c$ = "2"
ghost(2).x = (lx - 1) * 32
ghost(2).y = 8
ghost(2).z = lz * 32
endif
if c$ = "3"
ghost(3).x = (lx - 1) * 32
ghost(3).y = 8
ghost(3).z = lz * 32
endif
if c$ = "4"
ghost(4).x = (lx - 1) * 32
ghost(4).y = 8
ghost(4).z = lz * 32
endif
if c$ = "5"
ghost(5).x = (lx - 1) * 32
ghost(5).y = 8
ghost(5).z = lz * 32
endif
next lx
inc lz
loop
l = 0
dec lx, 2
dec lz
pac.edge = lx * 32
make object 11, 1, 0
for bx = 0 to lx
for bz = 0 to lz
if l then add limb 11, l, 1
offset limb 11, l, bx * 32, -16, bz * 32
inc l
next bz
next bx
color object 11, rgb(32, 32, 32)
set object collision off 11
endfunction
function PlayMusic()
restore Music
if file exist("music.dat") then delete file "music.dat"
open to write 1,"music.dat"
do
read d$
if d$ = "EOF" then exit
for i = 1 to len(d$) step 2
write byte 1, GetByte(d$, i)
next i
loop
close file 1
load music "music.dat", 1 : loop music 1 : delete file "music.dat"
endfunction
function GetByte(d$, i)
h = asc(mid$(d$, i)) - 48
l = asc(mid$(d$, i + 1)) - 48
b = (h - (h > 9) * 7) << 4
b = b + (l - (l > 9) * 7)
endfunction b
Level:
data "#######################"
data "#..........#..........#"
data "#.###.####.#.####.###.#"
data "#o# #.# #.#.# #.# #o#"
data "#.###.####.#.####.###.#"
data "#.....................#"
data "#.###.#.#######.#.###.#"
data "#.....#....#....#.....#"
data "#####.#### # ####.#####"
data " #.# 1 #.# "
data "#####.# #--#### #.#####"
data "x . #2 3 4# . x"
data "#####.# ####--# #.#####"
data " #.# 5 #.# "
data "#####.# ####### #.#####"
data "#..........#..........#"
data "#.###.####.#.####.###.#"
data "#o..#......c......#..o#"
data "###.#.#.#######.#.#.###"
data "#.....#....#....#.....#"
data "#.########.#.########.#"
data "#.....................#"
data "#######################"
data "EOL"
Music:
data "4D546864000000060001000701E04D54726B0000001E00FF5405600000000000FF510306FD1F00FF"
data "58040402180881A500FF2F004D54726B0000005200FF04024D3100FF0305506164203200C0591090"
data "3C578B11305DCA0938528825803C401330409261903C57874E305581078038409C1A3C400030405A"
data "903C578360803C40873590305D836280304000FF2F004D54726B0000042300FF0405497463687900"
data "FF03054472756D738742994636815C89464014994636815C8946401599466C815C8946401399466C"
data "815C89464015994636815B89464015994636815B8946401699461681598946401699462E815B8946"
data "401599466C815B8946401499466C784536658946400045401499466C024536628945401399453664"
data "8946400045401499466C004536648945401599453663894640004540179945366189454015994536"
data "638945401699450D638945401399454C648945401499456C648945401499456C648945401499456C"
data "648945401499456C648945401599456C638945401499454664894540149945366489454014994536"
data "64894540149945366489454014994536648945401499453664894540149945366489454016994536"
data "62894540810C99453664894540149945366489454014994536658945401399453664894540149945"
data "3664894540149945126489454014994569648945401599456C638945401499456C64894540149945"
data "6C648945401599453663894540149945366589454014994536638945408110994636815989464014"
data "994636815B89464014994636815C8946401599466C815B8946401399466C815D8946401499466C81"
data "5C89464015994636815C89464013994636815D89464015994603815B8946401499466C815C894640"
data "1299466C815D8946401499466C815D8946401299466C815D8946401599466C815C8946401499466C"
data "815C89464012994636815E894640827C994536658945401499453663894540149945366489454014"
data "99453664894540139945366589454014994536638945401499453664894540149945366589454014"
data "99453664894540149945366389454015994536638945401699453663894540149945366589454017"
data "9945365F894540159945366389454015994516648945401499453664894540139945686589454013"
data "99456C658945401499456C648945401399456C648945401699453663894540129945366589454015"
data "99463600453664894540149945366489464000454013994636004536648945401599452263894640"
data "0045401399463600456C648945401699456C648946400045401E9946350145415889454014994536"
data "648946400045401599466C815B8946401499466C815C89464015994636815B89464013994636815D"
data "89464015994617815A8946401599466C815D8946401499466C004536648945401599453662894640"
data "0045401499466C0145366489454012994536658946400045401599466C0045366289454015994536"
data "6589464000454013994636004506658945401499453E638946400045401599456C64894540159945"
data "6C628945401499456C64894540149945386489454014994636815D8946401399463B815C89464015"
data "99466C815B8946408755994636815B89464014994636815D8946401499466C815C8946401399466C"
data "815D89464011FF2F004D54726B000000D900FF040C50726F746575732F3120585200FF0305506961"
data "6E6F00C1000A914F27034B250148260043239C3B8143400E4840474B4066914B2E03493301442A9C"
data "648144401E4F40004B4022494059914F2E034B2E0048370243309C1D814840034340374B40154F40"
data "810F914F1F034B2E01492F00462F8E66814B40014940024F400546400E914D2F034B2B01492A0044"
data "298E10814B40094940064440044D405C914F27034B250248260343239C398143400F4840454B406A"
data "914F27024B2502482600432383608148400043408B184F40004F40004B4000FF2F004D54726B0000"
data "004A00FF040C50726F746575732F3120585200FF030D537472696E6720456E732E203200C2310D92"
data "3071D97A2C6E2C8230409D5692246E17822C409D432440269230718E7A82304000FF2F004D54726B"
data "0000009D00FF040C50726F746575732F3120585200FF0305506164203500C35C883A9348448A274B"
data "4D8112834840862F934D4F73834B40845E934F4C31834D408C5F934D4868834F408E624D40812693"
data "485B8D104B5B4F8348408579934D554A834B4086769352534F834D408D39934F4A22835240910E4F"
data "40860793485387414B535A834840866693544C45834B40876D5440883D934844864983484000FF2F"
data "004D54726B0000003A00FF0307547261636B203100FF022531393937204A6F65204765727368656E"
data "202F204561742D41742D4A6F652773204D7573696381A500FF2F00", "EOF"
[/spoiler]