Grundgrüst für ein 3D Spiel
Übersicht

sven123Betreff: Grundgrüst für ein 3D Spiel |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Mal sehen was ihr davon halte!Diese Sammlung von Funktionen ist für Anfänger gedacht.All diese funktionen stammen aus meinem neusten Projekt.Allerdings stellt dies kein Tutorial dar sondern eine Funktionssammlung.
Code: [AUSKLAPPEN] ;Laden der Meshs und Texturen ;Voreinstellunge der Cam und anderer Dinge die nicht in die Schleife gehören skybox(Elemente,gx,gy,gz,px,py,pz,Textur,collsky) Baeume(anzahl,collisionNumber,realPositionx,realPositiony,realPositionz,copyPositionrndx1,copyPositionrndx2,constanty,copyPositionrndz1,copyPositionrndz2) Haus1(anzahl,collisionNumber,realPositionx,realPositiony,realPositionz,copyPositionrndx1,copyPositionrndx2,constanty,copyPositionrndz1,copyPositionrndz2) ;Hauptschleife für spiel Ablauf Repeat steuerung(entity,oben,unten,rechts,links,lspeed,rspeed,zspeed) Fall(Objekt,cw#,OG#,LD#,g#,AO#,up) If KeyDown(57) Then add_bullet(sprite,max_life,speed#,cam) move_bullets() Until KeyDown(1) End ;Skybox Function skybox(Elemente,gx,gy,gz,px,py,pz,Textur,collsky) sky=CreateSphere(Elemente) FlipMesh sky ScaleEntity sky,gx,gy,gz PositionEntity sky,px,py,pz EntityTexture sky,Textur EntityType sky,collsky EntityOrder sky,1 Collisions camcoll,collsky,2,1 End Function ;erstellt die Bulletsprites Function add_bullet(sprite,max_life,speed#,cam) b.bullets=New bullets b\sprite=CopyEntity (sprite) EntityFX sprite,16 b\max_life=120 b\speed#=speed# EntityType b\sprite,ColSchuss EntityRadius b\sprite,10 PositionEntity b\sprite,EntityX(cam),EntityY(cam),EntityZ(cam) RotateEntity b\sprite,EntityPitch(cam),EntityYaw(cam),EntityRoll(cam) RotateSprite b\sprite,angelsprite If angelsprite > 360 Then angelsprite=0 angelsprite=angelsprite+10 ShowEntity b\sprite End Function ; ;bewegt die sprites Function move_bullets() For b.bullets=Each bullets MoveEntity b\sprite,0,0,b\speed# b\life=b\life+1 If b\life>b\max_life Then FreeEntity b\sprite : Delete b Next End Function ;Bäume setzen Function Baeume(anzahl,collisionNumber,realPositionx,realPositiony,realPositionz,copyPositionrndx1,copyPositionrndx2,constanty,copyPositionrndz1,copyPositionrndz2) Baumstumpf=LoadMesh("H:\Baumstumpf.x") PositionEntity Baumstumpf,realPositionx,realPositiony,realPositionz For a=1 To anzahl Baum=CopyEntity (Baumstumpf) PositionEntity Baum,Rnd#(copyPositionrndx1,copyPositionrndx2),constanty,Rnd#(copyPositionrndz1,copyPositionrndz2) EntityType Baum,collisionNumber EntityType Baumstumpf,collisionNumber Next End Function ;Screenshots Function screenshot(key) If KeyHit(key)=1 Then tasten=1 SaveBuffer BackBuffer(),"H:\Screenshots.bmp" tasten=0 EndIf End Function ;Steuerung Function steuerung(entity,oben,unten,rechts,links,lspeed,rspeed,zspeed) mxs=MouseXSpeed() mys=MouseYSpeed() MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 RotateEntity entity,EntityPitch(entity)+mys,EntityYaw(entity)-mxs,0 If KeyDown(oben)=1 Then MoveEntity entity,0,0,zspeed If KeyDown(links)=1 Then MoveEntity entity,lspeed,0,0 If KeyDown(rechts)=1 Then MoveEntity entity,rspeed,0,0 End Function ;Fall mit Luftreibung Function Fall(Objekt,cw#,OG#,LD#,g#,AO#,up) G1#=0.5*cw#*LD#*AO# G2#=OG*g Ggesamt#=G2#/G1# Fall#=Ggesamt#^0.5 If Not KeyDown(up) Then MoveEntity Objekt,0,-Fall#,0 End Function ;End Funktion Function Ende(B1,B2,B3,B4,B5,Modell) MaskImage B5,255,255,255 If GameOver=1 Then DrawImage B5,0,0 ;Anzeigen von 2 Buttons z.B ja und nein!!!!!! If sperre=0 Then DrawImage B2,xButtonja,yButtonja DrawImage B3,xButtonNein,yButtonNein If KeyDown(28) And sperre=0 Then GameOver=0 steuerung=0 PositionEntity Modell,5100,2050,8075 PositionEntity Modell,3007,4025,5845 TurnEntity Modell,10,106,0 TurnEntity Modell,270,0,27 EndIf EndIf ;Makierung der Buttons bei Tastendruck If KeyDown(205) Then sperre1=1 sperre=1 sperre2=0 EndIf If KeyDown(203) Then sperre2=1 sperre=1 sperre1=0 EndIf If sperre=1 Then DrawImage B1,xButtonja,yButtonja DrawImage B4,xButtonNein,yButtonNein If KeyDown(28)=1 And sperre1=1 Then End EndIf If sperre2=1 Then DrawImage B2,xButtonja,yButtonja DrawImage B3,xButtonNein,yButtonNein ;Neustart des Games durch Variabelen zurücksetzen If KeyDown(28)=1 And sperre2=1 Then GameOver=0 steuerung=0 PositionEntity Modell,5100,2050,8075 PositionEntity Modell,3007,4025,5845 TurnEntity Modell,10,106,0 TurnEntity Modell,270,0,27 EndIf EndIf EndIf End Function ;Gebäude setzen Function Haus1(anzahl,collisionNumber,realPositionx,realPositiony,realPositionz,copyPositionrndx1,copyPositionrndx2,constanty,copyPositionrndz1,copyPositionrndz2) Gebaude=LoadMesh("H:\house.x") PositionEntity Gebaude,realPositionx,realPositiony,realPositionz For a=1 To anzahl Hauser=CopyEntity (Gebaude) PositionEntity Hauser,Rnd#(copyPositionrndx1,copyPositionrndx2),constanty,Rnd#(copyPositionrndz1,copyPositionrndz2) EntityType Hauser,collisionNumber EntityType Hauser,collisionNumber Next End Function |
||
Amd Athlon 2200+,Saphire Atlantis Radeon9800pro,1024 MB DDR RAm,40 Gb Festblatte.
'in shâ'a llâh=so Gott will Fertiges Projekt:Invasion der Heuschrecken |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group