HSPでゲームらしいゲームを作ったことない僕ですが、初めてそれっぽい何かを作ってみました。
HSPでゲームらしいゲームを作ったことない僕ですが、初めてそれっぽい何かを作ってみました。
#cmpopt varinit 1#const global dispX 640#const global dispY 480#const global keyLeft 37#const global keyRight 39#const global keyJump 38#const global margin 50#const global fieldTop margin#const global fieldBottom dispY-margin#const global fieldLeft margin#const global fieldRight dispX-margin#module man speed,jumpPower,_width,_height,_x,_y,isAir,isHold,g,jPow#modcfunc manLeftreturn _x-_width/2#modfunc manSetLeft int left_x=left+_width/2return#modcfunc manRightreturn _x+_width/2#modfunc manSetRight int right_x=right-_width/2return#modcfunc manTopreturn _y-_height#modcfunc xreturn _x#modcfunc yreturn _y#define new(%1,%2,%3,%4,%5,%6,%7) dimtype %1,5:newmod %1,man,%2,%3,%4,%5,%6,%7#modinit int __speed,int __jumpPower,int __width,int __height,int __x,int __yspeed=__speedjumpPower=__jumpPower_width=__width_height=__height_x=__x_y=__yisAir=1isHold=0return#modfunc manMovedim keyPressgetkey keyPress,keyLeftif keyPress: _x-=speedgetkey keyPress,keyRightif keyPress: _x+=speedif manLeft(thismod)<=fieldLeft {manSetLeft thismod,fieldLeft}else:if fieldRight<=manRight(thismod) {manSetRight thismod,fieldRight}getkey keyPress,keyJumpif isAir {if isHold {if keyPress {jPow–if jPow<0: jPow=0_y-=jPow}else: isHold=0}g++_y+=gif fieldBottom<=_y {_y=fieldBottom-1isAir=0}}else:if keyPress {if 1!isHold {jPow=jumpPower_y-=jPowisHold=1isAir=1g=0}}else: isHold=0return#modfunc manViewcolor 0,0,$99boxf manLeft(thismod),manTop(thismod),manRight(thismod),_yreturn#global#module Program#defcfunc gKey int codedim refGetgetkey refGet,codereturn refGet#deffunc mainscreen 0,dispX,dispYnew@man bBox,6,22,32,32,dispX/2,dispY/2repeatmanMove bBoxredraw 0color $DD,$EE,$FFboxfcolor $33,$99,$FFboxf fieldRightboxf ,fieldBottomboxf ,,fieldLeftboxf ,,,fieldTopmanView bBoxcolor $FF,0,0pos margin/2,margin/2mes strf("x:%d y:%d",x(bBox),y(bBox))redraw 1wait 2loopreturn#globalmain