1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
;/////////////////////////////
;/ DREAM OF WORLD - Essais 2 /
;/////////////////////////////
;////////////////////////////////////////////////////////// Fichiers à inclure obligatoirement
IncludePath "includes" : IncludeFile "n3xtD_PB.pbi"
;//////////////////////////////////////// Globales
Global anglex.f, angley.f, flagXDown.w
;///////////////////////////////////
Global mox.f, omx.f, moy.l, omy.l
;///////////////////////////////////
Global pitch.f, yaw.f
;///////////////////////
Global *app.l, Quit.l
;///////////////////////
Global width.l = 1024
;///////////////////////
Global height.l = 768
;Ouvre une fenêtre N3xt-D
*app = iCreateGraphics3D(1024,768)
; << OR >>
;*app = iCreateGraphics3D(800,600, 32, #False, #False, #EDT_DIRECT3D9)
If *app= #Null
End
EndIf
Global screenW.l = GetSystemMetrics_(#SM_CXSCREEN)
Global screenH.l = GetSystemMetrics_(#SM_CYSCREEN)
SetCurrentDirectory("media/")
;////////////////////////////// Ajoute en mémoire un fichier compressé
iAddZipFileArchive( "map-20kdm2.pk3" )
;////////////////////////////////////// Chargement d'un objet
Global *obj.IObject = iLoad3DObject("20kdm2.bsp")
;////////////////////////////////////////// Creation d'un mesh avec l'objet chargé
Global *mesh.IMesh = iCreateMesh(*obj)
iScaleNode(*mesh, 1.5, 1.5, 1.5)
;/////////////////////////////////////// Creation et position de la camera
Global *cam.ICamera = iCreateCamera()
iPositionNode(*cam, 826, 550, 400)
;iRotateNode(*cam, 20,45, 0)
;///////////////////////////// Chargement du fond d'écran
iLoadFont("courriernew.png")
Global *font.IGUIFont = iGetFont()
;///////////////////////////////////
SetCurrentDirectory("animations/")
;//////////////////////////////////////// Chargement du ninja
Global *obj1.IObject = iLoad3DObject("ninja.b3d")
;////////////////////////// Position de la souris au milieu de la fenêtre
iPositionCursor(0.5, 0.5)
iVisibleCursorControl(#False) ;Souris invisible
;//////////////////////////////////////////////// Position des entitées
iPositionNode(*cam, 820, 545, 395)
;iRotateNode(*cam, 20, 45, 0)
;/////////////////////////////////////////////// Animation du ninja
*ninja.IAnimatedMesh = iCreateAnimation(*obj1)
iSpeedAnimation(*ninja, 10) ;On change le nombre pour changer la vitesse des animations
iRotateNode(*ninja, 20, 45, 0)
iPositionNode(*ninja, -10, 0, 10)
;/////////////////////////////// Collision du ninja avec le monde
*ninjaanim.IAnimatorCollisionResponse = iCreateCollisionResponseAnimator(*mesh, *ninja, 30, 50, 30, 0, 50, 0)
iAddCollisionResponse(*ninja, *ninjaanim)
;///////////////////////////////////////// Creation de la collision de la camera
*anim.IAnimatorCollisionResponse = iCreateCollisionResponseAnimator(*mesh, *cam, 30, 50, 30, 0, 50, 0)
iAddCollisionResponse(*cam, *anim)
;////////////////////////////////////////
; Boucle principale /
;////////////////////////////////////////
Repeat
;On bouge la camera avec les touches définis
If iGetKeyDown(#KEY_ARROW_UP)
iMoveNode(*cam, 0, 0, 5)
EndIf
;//////
If iGetKeyDown(#KEY_ARROW_DOWN)
iMoveNode(*cam, 0, 0, -5)
EndIf
;//////
If iGetKeyDown(#KEY_ARROW_LEFT)
iMoveNode(*cam, -5, 0, 0)
EndIf
;//////
If iGetKeyDown(#KEY_ARROW_RIGHT)
iMoveNode(*cam, 5, 0, 0)
EndIf
;//////
If iGetKeyDown(#KEY_SPACE)
iJumpCollisionResponse(*anim, 1.1)
EndIf
omx=iGetMouseX()-width/2
omy=iGetMouseY()-height/2
iPositionCursorControl(width/2,height/2)
pitch=pitch+omy/10
yaw=yaw-omx/10
iRotateNode(*cam,pitch,-yaw,0)
;Quitte la fenêtre quand on appuit sur la touche Echap
If iGetKeyDown(#KEY_ESCAPE)
Quit=1
EndIf
iBeginScene(0, 0, 0)
iDrawScene()
iDrawText(*font, "Utilisez les flèches pour bouger et Espace pour sauter", 10,10,0,0)
iEndScene()
Until Quit=1
;///////////// Fin
iFreeEngine() |
Partager