// MOAを使うことによりモーションの変化部分が自動補間されなめらかになります。 // キャラ1は矢印キーで移動、Bで突き、Nでキック、Mで防御。BNMをすばやく押すと投げ技 // キャラ2はWSADで移動、Zで突き、Xでキック、Cで防御。ZXCをすばやく押すと投げ技 #include "e3dhsp3.as" GROUND_SIZE = 60000.0 GROUND_DIVX = 30 GROUND_DIVZ = 30 GROUND_HEIGHT = 0.0 GRAVITY = -3.0 NAGEY = 70.0 HPMAX = 20000 #const global ICI_HSID 0 #const global ICI_QID 1 #const global ICI_MOTID 2 #const global ICI_FRAMENO 3 #const global ICI_NAGE 4 #const global ICI_NAGERARE 5 #const global ICI_HP 6 #const global ICI_MAX 7 dim ici, 2, ICI_MAX #const global DCI_POSX 0 #const global DCI_POSY 1 #const global DCI_POSZ 2 #const global DCI_NAGEVY 3 #const global DCI_BEFPOSX 4 #const global DCI_BEFPOSY 5 #const global DCI_BEFPOSZ 6 #const global DCI_MAX 7 ddim dci, 2, DCI_MAX #const global MOT_IDLING 0 #const global MOT_WALK 1 #const global MOT_TSUKI 2 #const global MOT_KICK 3 #const global MOT_DEFENCE 4 #const global MOT_MOCHIAGE 5 #const global MOT_JITABATA 6 #const global MOT_NAGERARE 7 #const global MOT_TSUNAGI 8 dim keybuf, 256 screenw = 640 : screenh = 480 screen 0, screenw, screenh, 1 title "Easy3D for HSP3 sample" ;開発中は下の行のコメントアウトを外すことを推奨します。 ;E3DEnableDbgFile ;初期化 E3DInit 0, -1, 0, 16, 0, scid1 cameradist = 3000 cameraheight = 800 camposx = GROUND_SIZE / 2 : camposy = GROUND_HEIGHT + cameraheight : camposz = ( GROUND_SIZE / 2 ) - cameradist proj_near = 500.0 : proj_far = 50000.0 : proj_fov = 60.0 E3DSetProjection proj_near, proj_far, proj_fov pathbuf0 = dir_cur + "\\Media\\poo\\poo.sig" E3DSigLoad pathbuf0, ici( 0, ICI_HSID ) dci( 0, DCI_POSX ) = 1000.0 : dci( 0, DCI_POSY ) = GROUND_HEIGHT : dci( 0, DCI_POSZ ) = 0.0 E3DSetPos ici( 0, ICI_HSID ), dci( 0, DCI_POSX ), dci( 0, DCI_POSY ), dci( 0, DCI_POSZ ) E3DSetToonEdge0Color ici( 0, ICI_HSID ), -1, "dummy", 255, 0, 0 E3DSetToonEdge0Width ici( 0, ICI_HSID ), -1, "dummy", 10.0 E3DRotateY ici( 0, ICI_HSID ), 90 pathbuf0 = dir_cur + "\\Media\\poo\\poo.moa" E3DLoadMOAFile ici( 0, ICI_HSID ), pathbuf0, 10 E3DCreateQ ici( 0, ICI_QID ) E3DSetBeforePos ici( 0, ICI_HSID ) ici( 0, ICI_HP ) = HPMAX pathbuf0 = dir_cur + "\\Media\\poo\\poo.sig" E3DSigLoad pathbuf0, ici( 1, ICI_HSID ) dci( 1, DCI_POSX ) = -1000.0 : dci( 1, DCI_POSY ) = GROUND_HEIGHT : dci( 1, DCI_POSZ ) = 0.0 E3DSetPos ici( 1, ICI_HSID ), dci( 1, DCI_POSX ), dci( 1, DCI_POSY ), dci( 1, DCI_POSZ ) E3DSetToonEdge0Color ici( 1, ICI_HSID ), -1, "dummy", 0, 0, 255 E3DSetToonEdge0Width ici( 1, ICI_HSID ), -1, "dummy", 10.0 E3DRotateY ici( 1, ICI_HSID ), -90 pathbuf0 = dir_cur + "\\Media\\poo\\poo.moa" E3DLoadMOAFile ici( 1, ICI_HSID ), pathbuf0, 10 E3DCreateQ ici( 1, ICI_QID ) E3DSetBeforePos ici( 1, ICI_HSID ) ici( 1, ICI_HP ) = HPMAX E3DGetMotionNum ici( 0, ICI_HSID ), motnum dim motionid, motnum E3DGetMotionIDByName ici( 0, ICI_HSID ), "idling", motionid( MOT_IDLING ) E3DGetMotionIDByName ici( 0, ICI_HSID ), "walk", motionid( MOT_WALK ) E3DGetMotionIDByName ici( 0, ICI_HSID ), "tsuki", motionid( MOT_TSUKI ) E3DGetMotionIDByName ici( 0, ICI_HSID ), "kick", motionid( MOT_KICK ) E3DGetMotionIDByName ici( 0, ICI_HSID ), "defence", motionid( MOT_DEFENCE ) E3DGetMotionIDByName ici( 0, ICI_HSID ), "mochiage", motionid( MOT_MOCHIAGE ) E3DGetMotionIDByName ici( 0, ICI_HSID ), "jitabata", motionid( MOT_JITABATA ) E3DGetMotionIDByName ici( 0, ICI_HSID ), "nagerare", motionid( MOT_NAGERARE ) E3DGetMotionIDByName ici( 0, ICI_HSID ), "tsunagi", motionid( MOT_TSUNAGI ) pathbuf0 = dir_cur + "\\Media\\bmpfile\\a007bcg.bmp" E3DCreateBG scid1, pathbuf0, "dummy", 0, 0, 0 pathbuf0 = dir_cur + "\\Media\\bmpfile\\gplane.mqo" E3DLoadMQOFileAsGround pathbuf0, 100.0, groundhsid lightdirx1 = 0.0 : lightdiry1 = -1.0 : lightdirz1 = 1.0 lightr1 = 255 : lightg1 = 255 : lightb1 = 255 E3DCreateLight lid1 E3DSetDirectionalLight lid1, lightdirx1, lightdiry1, lightdirz1, lightr1, lightg1, lightb1 confflag = 0 gameflag = 0 *main E3DGetKeyboardCnt keybuf if keybuf.VK_ESCAPE = 1 : goto *bye ; [ESC]で終了 if( gameflag == 0 ){ chara1 = 0 : chara2 = 1 key1 = VK_UP : key2 = VK_DOWN : key3 = VK_LEFT : key4 = VK_RIGHT : key5 = 'B' : key6 = 'N' : key7 = 'M' gosub *MoveChara chara1 = 1 : chara2 = 0 key1 = 'W' : key2 = 'S' : key3 = 'A' : key4 = 'D' : key5 = 'Z' : key6 = 'X' : key7 = 'C' gosub *MoveChara gosub *MoveCamera } E3DChkInView scid1, groundhsid E3DChkInView scid1, ici( 0, ICI_HSID ) E3DChkInView scid1, ici( 1, ICI_HSID ) if( gameflag == 0 ){ gosub *ChkConfChara chara1 = 0 : chara2 = 1 : gosub *ChangeHP chara1 = 1 : chara2 = 0 : gosub *ChangeHP gosub *ChkGameOver } E3DBeginScene scid1 E3DRender scid1, groundhsid, 0, 0, 0 E3DRender scid1, ici( 0, ICI_HSID ), 0, 0, 0 E3DRender scid1, ici( 1, ICI_HSID ), 0, 0, 0 gosub *DrawText E3DEndScene E3DPresent scid1 E3DSetBeforePos ici( 0, ICI_HSID ) E3DSetBeforePos ici( 1, ICI_HSID ) E3DWaitbyFPS 60, chkfps1 await 0 goto *main *bye E3DBye end *MoveCamera centerx = ( dci( 0, DCI_POSX ) + dci( 1, DCI_POSX ) ) / 2.0 centery = ( dci( 0, DCI_POSY ) + dci( 1, DCI_POSY ) ) / 2.0 centerz = ( dci( 0, DCI_POSZ ) + dci( 1, DCI_POSZ ) ) / 2.0 diffx = dci( 1, DCI_POSX ) - dci( 0, DCI_POSX ) diffy = dci( 1, DCI_POSY ) - dci( 0, DCI_POSY ) diffz = dci( 1, DCI_POSZ ) - dci( 0, DCI_POSZ ) if( (diffx != 0) | (diffy != 0) | (diffz != 0) ){ mag = (diffx * diffx) + (diffy * diffy) + (diffz * diffz) E3DSqrt mag, charadist cameradist = 2000 + ( charadist * 0.33 ) E3DCross diffx, diffy, diffz, 0, 1, 0, crossx, crossy, crossz camposx = centerx + crossx * cameradist camposy = centery + cameraheight camposz = centerz + crossz * cameradist camdirx = centerx - camposx camdiry = 0 camdirz = centerz - camposz cameradiv = 3 E3DSetCameraPos camposx, camposy, camposz E3DCameraLookAt camdirx, camdiry, camdirz, 0, cameradiv } return *MoveChara if( ici( chara1, ICI_NAGERARE ) == 0 ){ eventno = 0 if( keybuf.key5 == 1 ) : eventno = 2 if( keybuf.key6 == 1 ) : eventno = 4 if( keybuf.key7 == 1 ) : eventno = 8 if( (keybuf.key5 != 0) || (keybuf.key6 != 0) ){ E3DPosForward ici( chara1, ICI_HSID ), 5 E3DGetPos ici( chara1, ICI_HSID ), dci( chara1, DCI_POSX ), dci( chara1, DCI_POSY ), dci( chara1, DCI_POSZ ) } if( eventno == 0 ){ if( keybuf.key1 != 0 ){ E3DPosForward ici( chara1, ICI_HSID ), 18 E3DGetPos ici( chara1, ICI_HSID ), dci( chara1, DCI_POSX ), dci( chara1, DCI_POSY ), dci( chara1, DCI_POSZ ) eventno = 1 } if( keybuf.key2 != 0 ){ E3DPosForward ici( chara1, ICI_HSID ), -18 E3DGetPos ici( chara1, ICI_HSID ), dci( chara1, DCI_POSX ), dci( chara1, DCI_POSY ), dci( chara1, DCI_POSZ ) eventno = 1 } if( keybuf.key3 != 0 ) : E3DRotateY ici( chara1, ICI_HSID ), 2 : eventno = 1 if( keybuf.key4 != 0 ) : E3DRotateY ici( chara1, ICI_HSID ), -2 : eventno = 1 } if( (ici( chara1, ICI_MOTID ) == motionid( MOT_MOCHIAGE )) && (ici( chara1, ICI_NAGE) == 0) && (ici( chara2, ICI_NAGERARE ) == 0) ){ E3DDirToTheOther ici( chara1, ICI_HSID ), ici( chara2, ICI_HSID ) diffx = dci( chara1, DCI_POSX ) - dci( chara2, DCI_POSX ) diffy = dci( chara1, DCI_POSY ) - dci( chara2, DCI_POSY ) diffz = dci( chara1, DCI_POSZ ) - dci( chara2, DCI_POSZ ) mag = diffx * diffx + diffy * diffy + diffz * diffz if( mag < 900000 ){ ici( chara1, ICI_NAGE ) = 1 ici( chara2, ICI_NAGERARE ) = 1 dci( chara2, DCI_NAGEVY ) = NAGEY E3DGetBonePos ici( chara1, ICI_HSID ), 18, 1, ici( chara1, ICI_MOTID ), ici( chara1, ICI_FRAMENO ), posx, posy, posz, 1 E3DGetDirQ2 ici( chara1, ICI_HSID ), ici( chara1, ICI_QID ) E3DMultQVec ici( chara1, ICI_QID ), 0, 0, -1, dirx, diry, dirz dci( chara2, DCI_POSX ) = posx + dirx * 300 dci( chara2, DCI_POSY ) = posy - 300 dci( chara2, DCI_POSZ ) = posz + dirz * 300 E3DSetPos ici( chara2, ICI_HSID ), dci( chara2, DCI_POSX ), dci( chara2, DCI_POSY ), dci( chara2, DCI_POSZ ) E3DGetBoneQ ici( chara1, ICI_HSID ), 18, ici( chara1, ICI_MOTID ), ici( chara1, ICI_FRAMENO ), 2, ici( chara2, ICI_QID ) E3DSetDirQ2 ici( chara2, ICI_HSID ), ici( chara2, ICI_QID ) E3DSetNewPoseByMOA ici( chara2, ICI_HSID ), 16 } } E3DSetNewPoseByMOA ici( chara1, ICI_HSID ), eventno }else{ ici( chara1, ICI_NAGERARE ) += 1 if( ici( chara1, ICI_NAGERARE ) < 50 ){ E3DSetNewPoseByMOA ici( chara1, ICI_HSID ), 16 }else{ if( ici( chara1, ICI_NAGERARE ) < 120 ){ E3DGetDirQ2 ici( chara2, ICI_HSID ), ici( chara2, ICI_QID ) E3DMultQVec ici( chara2, ICI_QID ), 0, 0, -1, dirx, diry, dirz dci( chara1, DCI_POSX ) += dirx * 20.0 dci( chara1, DCI_POSZ ) += dirz * 20.0 dci( chara1, DCI_NAGEVY ) += GRAVITY dci( chara1, DCI_POSY ) += dci( chara1, DCI_NAGEVY ) if( dci( chara1, DCI_POSY ) < GROUND_HEIGHT ) : dci( chara1, DCI_POSY ) = GROUND_HEIGHT E3DSetPos ici( chara1, ICI_HSID ), dci( chara1, DCI_POSX ), dci( chara1, DCI_POSY ), dci( chara1, DCI_POSZ ) E3DSetNewPoseByMOA ici( chara1, ICI_HSID ), 32 }else{ ici( chara1, ICI_NAGERARE ) = 0 ici( chara2, ICI_NAGE ) = 0 dci( chara1, DCI_POSY ) = GROUND_HEIGHT E3DCopyQ ici( chara1, ICI_QID ), ici( chara2, ICI_QID ) E3DSetDirQ2 ici( chara1, ICI_HSID ), ici( chara1, ICI_QID ) E3DSetNewPoseByMOA ici( chara1, ICI_HSID ), 0 } } } E3DGetMotionFrameNo ici( chara1, ICI_HSID ), ici( chara1, ICI_MOTID ), ici( chara1, ICI_FRAMENO ) if( ici( chara1, ICI_MOTID ) == 0 ){ E3DGetNextMotionFrameNo ici( chara1, ICI_HSID ), 0, ici( chara1, ICI_MOTID ), tempframeno } return *ChkConfChara if( (ici( 0, ICI_NAGERARE ) == 0) && (ici( 1, ICI_NAGERARE ) == 0) ){ E3DChkConflict2 ici( 0, ICI_HSID ), -1, ici( 1, ICI_HSID ), -1, confflag, inviewflag }else{ confflag = 0 } if( confflag != 0 ){ E3DSeparateFrom ici( 0, ICI_HSID ), ici( 1, ICI_HSID ), 10 E3DSeparateFrom ici( 1, ICI_HSID ), ici( 0, ICI_HSID ), 10 } E3DGetPos ici( 0, ICI_HSID ), dci( 0, DCI_POSX ), dci( 0, DCI_POSY ), dci( 0, DCI_POSZ ) E3DGetPos ici( 1, ICI_HSID ), dci( 1, DCI_POSX ), dci( 1, DCI_POSY ), dci( 1, DCI_POSZ ) return *ChangeHP if( confflag != 0 ){ if( (ici( chara1, ICI_MOTID ) == motionid( MOT_TSUKI )) && (ici( chara2, ICI_MOTID ) != motionid( MOT_DEFENCE )) ){ ici( chara2, ICI_HP ) -= 100 } if( (ici( chara1, ICI_MOTID ) == motionid( MOT_KICK )) && (ici( chara2, ICI_MOTID ) != motionid( MOT_DEFENCE )) ){ ici( chara2, ICI_HP ) -= 200 } }else{ if( ici( chara1, ICI_NAGERARE ) != 0 ) : ici( chara1, ICI_HP ) -= 40 } return *DrawText textr = 0 : textg = 255 : textb = 255 : textscale = 1 : textposx = 10 : textposy = 10 strchk = "blue HP " + ici( 1, ICI_HP ) + " red HP " + ici( 0, ICI_HP ) E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk return *ChkGameOver if( ici( 0, ICI_HP ) <= 0 ){ gameflag = 1 E3DCreateBG scid1, dir_cur + "\\Media\\bmpfile\\bluewin.png", "dummy" } if( ici( 1, ICI_HP ) <= 0 ){ gameflag = 1 E3DCreateBG scid1, dir_cur + "\\Media\\bmpfile\\redwin.png", "dummy" } return