[AHK游戏]杀机丛丛的马路

 

[AHK游戏]杀机丛丛的马路

 

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance force
#MaxThreadsPerHotkey,1
SetBatchLines,-1
SetControlDelay,-1
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
speed:=100 ; in MS
,lives:=3
,difficulty:=3 ; 1-10
 
,score:=3000,flyCount:=0
,death:=0,fx:=128,fy:=320
;water object
,wox1_1:=48,wox1_2:=240,wox1_3:=394,wox1_4:=522
,wox2_1:=70,wox2_2:=240,wox2_3:=340,wox2_4:=574
,wox3_1:=102,wox3_2:=238,wox3_3:=434,wox3_4:=572
;vehicles
,vox1_1:=60,vox1_2:=172,vox1_3:=360,vox1_4:=540
,vox2_1:=-480,vox2_2:=36,vox2_3:=252,vox2_4:=384
,vox3_1:=-480,vox3_2:=72,vox3_3:=192,vox3_4:=330
;fly 1-5 visibility state
,f1v:=1,f2v:=1,f3v:=1,f4v:=1,f5v:=1
,Diff:=Mod(difficulty,11)
,Left:=0,Right:=0,Up:=0,Down:=0
 
 
;+-+-+-+-+-+-+-+-+          INTERFACE          +-+-+-+-+-+-+-+-+
;\ .________________________________________________________________________ . /
;`----------------------------------------------------------------------------´
 
Gui, Add, Picture, x0 y0 h384 w480, %A_scriptdir%\BackGround.jpg
 
;water objects
Gui, Add, Progress, c9f5000 x%wox1_1% y32 w80 h32 vlog1_1, 100
Gui, Add, Progress, c9f5000 x%wox1_2% y32 w80 h32 vlog1_2, 100
Gui, Add, Progress, c9f5000 x%wox1_3% y32 w80 h32 vlog1_3, 100
Gui, Add, Progress, c9f5000 x%wox1_4% y32 w80 h32 vlog1_4, 100
Gui, Add, Progress, c9f5000 x%wox2_1% y64 w64 h32 vlog2_1, 100
Gui, Add, Progress, c9f5000 x%wox2_2% y64 w64 h32 vlog2_2, 100
Gui, Add, Progress, c9f5000 x%wox2_3% y64 w64 h32 vlog2_3, 100
Gui, Add, Progress, c9f5000 x%wox2_4% y64 w64 h32 vlog2_4, 100
Gui, Add, Progress, c9f5000 x%wox3_1% y96 w96 h32 vlog3_1, 100
Gui, Add, Progress, c9f5000 x%wox3_2% y96 w96 h32 vlog3_2, 100
Gui, Add, Progress, c9f5000 x%wox3_3% y96 w96 h32 vlog3_3, 100
Gui, Add, Progress, c9f5000 x%wox3_4% y96 w96 h32 vlog3_4, 100
 
;vehicles
Gui, Add, Progress, cad5a5a x%vox1_1% y224 w64 h32 vcar1_1, 60
Gui, Add, Progress, cad5a5a x%vox1_2% y224 w64 h32 vcar1_2, 60
Gui, Add, Progress, cad5a5a x%vox1_3% y224 w64 h32 vcar1_3, 60
Gui, Add, Progress, cad5a5a x%vox1_4% y224 w64 h32 vcar1_4, 60
Gui, Add, Progress, c48deff x%vox2_1% y256 w72 h32 vcar2_1, 75
Gui, Add, Progress, c48deff x%vox2_2% y256 w72 h32 vcar2_2, 75
Gui, Add, Progress, c48deff x%vox2_3% y256 w72 h32 vcar2_3, 75
Gui, Add, Progress, c48deff x%vox2_4% y256 w72 h32 vcar2_4, 75
Gui, Add, Progress, cff48f1 x%vox3_1% y288 w56 h32 vcar3_1, 80
Gui, Add, Progress, cff48f1 x%vox3_2% y288 w56 h32 vcar3_2, 80
Gui, Add, Progress, cff48f1 x%vox3_3% y288 w56 h32 vcar3_3, 80
Gui, Add, Progress, cff48f1 x%vox3_4% y288 w56 h32 vcar3_4, 80
 
;Flies
Gui, Add, Button, x32 y16 w32 h16 +Disabled vf1, Fly
Gui, Add, Button, x96 y16 w32 h16 +Disabled vf2, Fly
Gui, Add, Button, x160 y16 w32 h16 +Disabled vf3, Fly
Gui, Add, Button, x224 y16 w32 h16 +Disabled vf4, Fly
Gui, Add, Button, x288 y16 w32 h16 +Disabled vf5, Fly
Gui, Add, Button, x400 y6 h20 gdbg vdbg, Debug
 
;frogger
Gui, Add, Progress, c008000 x%fx% y%fy% w16 h32 vfrogger, 100
 
Gui, font, bold s9, tahoma
Gui, add, text, x6 y344 c8eff8f +BackGroundTrans vHUD, lives: %lives%`nScore: %score%
Gui, Show,h384 w480, Frogger
 
;+-+-+-+-+-+-+-+-+          GAME LOOP          +-+-+-+-+-+-+-+-+
;\ .________________________________________________________________________ . /
;`----------------------------------------------------------------------------´
gameloop:
Loop{
Loop{ ; MAKE THE OBSTICLES MoveDraw LEFT<-->RIGHT
Gosub,Deathcheck
Log1:=Diff*3,Log2:=Diff*1,Log3:=Diff*2,Car1:=Diff*4,Car2:=Diff*2,Car3:=Diff*5
wox1_1-=Log1,wox1_2-=Log1,wox1_3-=Log1,wox1_4-=Log1
,wox2_1+=Log2,wox2_2+=Log2,wox2_3+=Log2,wox2_4+=Log2
,wox3_1-=Log3,wox3_2-=Log3,wox3_3-=Log3,wox3_4-=Log3
,vox1_1-=Car1,vox1_2-=Car1,vox1_3-=Car1,vox1_4-=Car1
,vox2_1+=Car2,vox2_2+=Car2,vox2_3+=Car2,vox2_4+=Car2
,vox3_1+=Car3,vox3_2+=Car3,vox3_3+=Car3,vox3_4+=Car3
If(fy=32){
GuiControl, MoveDraw, log1_1, x%wox1_1%
GuiControl, MoveDraw, log1_2, x%wox1_2%
GuiControl, MoveDraw, log1_3, x%wox1_3%
GuiControl, MoveDraw, log1_4, x%wox1_4%
}else{
GuiControl, Move, log1_1, x%wox1_1%
GuiControl, Move, log1_2, x%wox1_2%
GuiControl, Move, log1_3, x%wox1_3%
GuiControl, Move, log1_4, x%wox1_4%
}If(fy=64){
GuiControl, MoveDraw, log2_1, x%wox2_1%
GuiControl, MoveDraw, log2_2, x%wox2_2%
GuiControl, MoveDraw, log2_3, x%wox2_3%
GuiControl, MoveDraw, log2_4, x%wox2_4%
}else{
GuiControl, Move, log2_1, x%wox2_1%
GuiControl, Move, log2_2, x%wox2_2%
GuiControl, Move, log2_3, x%wox2_3%
GuiControl, Move, log2_4, x%wox2_4%
}If(fy=96){
GuiControl, MoveDraw, log3_1, x%wox3_1%
GuiControl, MoveDraw, log3_2, x%wox3_2%
GuiControl, MoveDraw, log3_3, x%wox3_3%
GuiControl, MoveDraw, log3_4, x%wox3_4%
}else{
GuiControl, Move, log3_1, x%wox3_1%
GuiControl, Move, log3_2, x%wox3_2%
GuiControl, Move, log3_3, x%wox3_3%
GuiControl, Move, log3_4, x%wox3_4%
}If(fy=224){
GuiControl, MoveDraw, car1_1, x%vox1_1%
GuiControl, MoveDraw, car1_2, x%vox1_2%
GuiControl, MoveDraw, car1_3, x%vox1_3%
GuiControl, MoveDraw, car1_4, x%vox1_4%
}else{
GuiControl, Move, car1_1, x%vox1_1%
GuiControl, Move, car1_2, x%vox1_2%
GuiControl, Move, car1_3, x%vox1_3%
GuiControl, Move, car1_4, x%vox1_4%
}If(fy=256){
GuiControl, MoveDraw, car2_1, x%vox2_1%
GuiControl, MoveDraw, car2_2, x%vox2_2%
GuiControl, MoveDraw, car2_3, x%vox2_3%
GuiControl, MoveDraw, car2_4, x%vox2_4%
}else{
GuiControl, Move, car2_1, x%vox2_1%
GuiControl, Move, car2_2, x%vox2_2%
GuiControl, Move, car2_3, x%vox2_3%
GuiControl, Move, car2_4, x%vox2_4%
}If(fy=288){
GuiControl, MoveDraw, car3_1, x%vox3_1%
GuiControl, MoveDraw, car3_2, x%vox3_2%
GuiControl, MoveDraw, car3_3, x%vox3_3%
GuiControl, MoveDraw, car3_4, x%vox3_4%
}else{
GuiControl, Move, car3_1, x%vox3_1%
GuiControl, Move, car3_2, x%vox3_2%
GuiControl, Move, car3_3, x%vox3_3%
GuiControl, Move, car3_4, x%vox3_4%
}
If(fy=32){
FrogOnSpeed:=-Log1
Gosub,LogMove
}else If(fy=64){
FrogOnSpeed:=Log2
Gosub,LogMove
}else If(fy=96){
FrogOnSpeed:=-Log3
Gosub,LogMove
}
; WRAP OBJECTS ONCE THEY ARE OUT OF VIEW
If(wox1_1<0)
wox1_4:=wox1_1+540
If(wox1_2<0)
wox1_1:=wox1_2+540
If(wox1_3<0)
wox1_2:=wox1_3+540
If(wox1_4<0)
wox1_3:=wox1_4+540
If(wox2_1>416)
wox2_2:=wox2_1-480
If(wox2_2>416)
wox2_3:=wox2_2-480
If(wox2_3>416)
wox2_4:=wox2_3-480
If(wox2_4>416)
wox2_1:=wox2_4-480
If(wox3_1<0)
wox3_4:=wox3_1+480
If(wox3_2<0)
wox3_1:=wox3_2+480
If(wox3_3<0)
wox3_2:=wox3_3+480
If(wox3_4<0)
wox3_3:=wox3_4+480
If(vox1_1<0)
vox1_4:=vox1_1+540
If(vox1_2<0)
vox1_1:=vox1_2+540
If(vox1_3<0)
vox1_2:=vox1_3+540
If(vox1_4<0)
vox1_3:=vox1_4+540
If(vox2_1>416)
vox2_2:=vox2_1-480
If(vox2_2>416)
vox2_3:=vox2_2-480
If(vox2_3>416)
vox2_4:=vox2_3-480
If(vox2_4>416)
vox2_1:=vox2_4-480
If(vox3_1>416)
vox3_2:=vox3_1-500
If(vox3_2>416)
vox3_3:=vox3_2-500
If(vox3_3>416)
vox3_4:=vox3_3-500
If(vox3_4>416)
vox3_1:=vox3_4-500
 
;FLY CODE.
If(fy=0 && fx>32 && fx<64 && f1v=1){
f1v:=0,fx:=128,fy:=320
GuiControl, MoveDraw, frogger, x%fx% y%fy%
lives+=1,score+=250,speed-=10,flyCount+=1
GuiControl, hide, f1
}
If(fy=0 && fx>96 && fx<128 && f2v=1){
f2v:=0,fx=128,fy:=320
GuiControl, MoveDraw, frogger, x%fx% y%fy%
lives+=1,score+=250,speed-=10,flyCount+=1
GuiControl, hide, f2
}
If(fy=0 && fx>160 && fx<192 && f3v=1){
f3v:=0,fx:=128,fy:=320
GuiControl, MoveDraw, frogger, x%fx% y%fy%
lives+=1,score+=250,speed-=10,flyCount+=1
GuiControl, hide, f3
}
If(fy=0 && fx>224 && fx<256 && f4v=1){
f4v:=0,fx:=128,fy:=320
GuiControl, MoveDraw, frogger, x%fx% y%fy%
lives+=1,score+=250,speed-=10,flyCount+=1
GuiControl, hide, f4
}
If(fy=0 && fx>288 && fx<320 && f5v=1){
f5v:=0,fx:=128,fy:=320
GuiControl, MoveDraw, frogger, x%fx% y%fy%
lives+=1,score+=250,speed-=10,flyCount+=1
GuiControl, hide, f5
}
If(fy<=0 || fy>=384 || fx>=480 || fx<=-1)
Gosub, death
score-=1
If flyCount=5
Gosub, win
If lives<=0
Gosub, lose
GuiControl,, HUD, lives: %lives%`nScore: %score%
Gosub,Deathcheck
Sleep %speed%
}}return
 
GuiClose:
ExitApp
 
deathcheck:
Gui, Submit, NoHide
Death:=0
If(fy=32){
If !((fx>wox1_1&&fx<wox1_1+80)
|| (fx>wox1_2&&fx<wox1_2+80)
|| (fx>wox1_3&&fx<wox1_3+80)
|| (fx>wox1_4&&fx<wox1_4+80))
Death:=1
}else If(fy=64){
If !((fx>wox2_1&&fx<wox2_1+64)
|| (fx>wox2_2&&fx<wox2_2+64)
|| (fx>wox2_3&&fx<wox2_3+64)
|| (fx>wox2_4&&fx<wox2_4+64))
Death:=1
}else If(fy=96){
If !((fx>wox3_1&&fx<wox3_1+96)
|| (fx>wox3_2&&fx<wox3_2+96)
|| (fx>wox3_3&&fx<wox3_3+96)
|| (fx>wox3_4&&fx<wox3_4+96))
Death:=1
}else If(fy=224){
If ((fx>vox1_1&&fx<vox1_1+64)
|| (fx>vox1_2&&fx<vox1_2+64)
|| (fx>vox1_3&&fx<vox1_3+64)
|| (fx>vox1_4&&fx<vox1_4+64))
Death:=1
}else If(fy=256){
If ((fx>vox2_1&&fx<vox2_1+72)
|| (fx>vox2_2&&fx<vox2_2+72)
|| (fx>vox2_3&&fx<vox2_3+72)
|| (fx>vox2_4&&fx<vox2_4+72))
Death:=1
}else If(fy=288){
If ((fx>vox3_1&&fx<vox3_1+56)
|| (fx>vox3_2&&fx<vox3_2+56)
|| (fx>vox3_3&&fx<vox3_3+56)
|| (fx>vox3_4&&fx<vox3_4+56))
Death:=1
}If Death
Gosub, death
Return
 
death:
Gui, Submit, NoHide
fx:=128,fy:=320
GuiControl, MoveDraw, frogger, x%fx% y%fy%
lives-=1,score-=100
GuiControl,, HUD, lives: %lives%`nScore: %score%
Return
 
#If !(Down=1||Left=1||Right=1)
up::
fy-=32,FrogOn:=0,Up:=1
GuiControl, MoveDraw, frogger, y%fy%
Gosub, deathcheck
Sleep,%speed%
Up:=0
return
#If !(Up=1||Left=1||Right=1)
down::
fy+=32,FrogOn:=0,Down:=1
GuiControl, MoveDraw, frogger, y%fy%
Gosub, deathcheck
Sleep,%speed%
Down:=0
return
#If !(Up=1||Down=1||Right=1)
left::
fx-=32,FrogOn:=0,Left:=1
GuiControl, MoveDraw, frogger, x%fx%
Gosub, deathcheck
Sleep,%speed%
Left:=0
return
#If !(Up=1||Down=1||Left=1)
right::
fx+=32,FrogOn:=0,Right:=1
GuiControl, MoveDraw, frogger, x%fx%
Gosub, deathcheck
Sleep,%speed%
Right:=0
return
#If
LogMove:
fx+=FrogOnSpeed
GuiControl, MoveDraw, frogger, x%fx%
return
 
 
;+-+-+-+-+-+-+-+-+         DEBUG DIALOGUE         +-+-+-+-+-+-+-+-+
;\ .________________________________________________________________________ . /
;`----------------------------------------------------------------------------´
dbg:
GuiControl, hide, dbg
Gui, Add, text, cwhite BackgRoundTrans x360 y128 w100 vdisp,
(
X: %fx%, Y: %fy%
 
Death: %death%
)
SetTimer, disp, 200
return
 
disp:
Gui, Submit, NoHide
GuiControl, , disp,
(
X: %fx%, Y: %fy%
 
Death: %death%
)
return
 
win:
MsgBox, 
(
%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%@..@
%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%(------)
%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%<%A_Space%I%A_Space%%A_Space%%A_Space%%A_Space%I%A_Space%>
%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%"%A_Space%%A_Space%%A_Space%%A_Space%"
Congratulations, you won!
Made by tidbit of the AHK forums.
Frog from: http://chris.com/ascii/ modified by tidbit.
)
Reload
Return
lose:
MsgBox, 
(
%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%X..X
%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%(------)
%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%<%A_Space%I%A_Space%%A_Space%%A_Space%%A_Space%I%A_Space%>
%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%%A_Space%"%A_Space%%A_Space%%A_Space%%A_Space%"
Congratulations, you lost.
Made by tidbit of the AHK forums.
Frog from: http://chris.com/ascii/ modified by tidbit.
)
Reload
Return
 
Pause::Pause
esc::ExitApp

 

给TA捐赠
共{{data.count}}人
人已捐赠
其他

有时候我们希望程序运行之后就能自杀,这里就提供一个能自杀的脚本实例

2018-2-1 20:15:30

其他应用

[AHK游戏]AHKRoid

2018-2-2 19:41:28

2 条回复 A文章作者 M管理员
  1. AHKiller

    ?

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索