Well you CAN do something useful with Engine3d
- 
				dracflamloc
 - Addict

 - Posts: 1648
 - Joined: Mon Sep 20, 2004 3:52 pm
 - Contact:
 
Well you CAN do something useful with Engine3d
Check out this FP shooter accuracy tester:
http://dracsoft.com/zips/FPSTester.zip
			
			
									
									
						http://dracsoft.com/zips/FPSTester.zip
Re: Well you CAN do something useful with Engine3d
Wow, that's pretty impressive!  I didn't expect to see something that good!   
Has the same feel as the Quake games, which is a great achievement.
You're saving BMPs with a PNG extension though, as reported by IrfanView:
			
			
									
									
						Has the same feel as the Quake games, which is a great achievement.
You're saving BMPs with a PNG extension though, as reported by IrfanView:
Code: Select all
---------------------------
IrfanView
---------------------------
Warning !
The file: "E:\~ Temp ~\2007-10-4 1191507307\shot1.png" is a BMP file with incorrect extension !
Rename ?
---------------------------
Yes   No
---------------------------
- 
				dracflamloc
 - Addict

 - Posts: 1648
 - Joined: Mon Sep 20, 2004 3:52 pm
 - Contact:
 
- Kaeru Gaman
 - Addict

 - Posts: 4826
 - Joined: Sun Mar 19, 2006 1:57 pm
 - Location: Germany
 
- 
				dracflamloc
 - Addict

 - Posts: 1648
 - Joined: Mon Sep 20, 2004 3:52 pm
 - Contact:
 
THe source would make your eyes bleed. Trust me its for your own good.
But in case you want to torture yourself:
			
			
													But in case you want to torture yourself:
Code: Select all
;FPSTrainer - Copyright 2007 DracSoft - License: GNU GPL (www.gnu.org)
;todo - 'session log' of screenshots of every shot fired in a datetimed directory
;todo - 'onscreen accuraccy + totals
Define.f KeyX, KeyY, MouseX, MouseY
#RobotMesh    = 90
#RobotTexture = 90
#Robot        = 90
movex.f = Random(100)/100+0.5
movez.f = Random(100)/100+0.5
movey.f = Random(100)/100+0.5
scTerSize = 1024
mLwasdown = 0
isfullscreen=Val(ProgramParameter())
maxTime = Val(ProgramParameter())  
startMs = ElapsedMilliseconds()
shotsFired.f=0
shotsHit.f=0
shotCounter=0
sessionFolder.s=Str(Year(Date()))+"-"+Str(Month(Date()))+"-"+Str(Day(Date()))+" "+Str(Date())
  
If InitEngine3D()
  Add3DArchive("\", #PB_3DArchive_FileSystem)
  
  InitSound()
  InitSprite()
  UsePNGImageDecoder()
  UsePNGImageEncoder()
  UseOGGSoundDecoder()
  InitKeyboard()
  InitMouse()
  
  LoadSound(0,"./hit.ogg")
  LoadSound(1,"./miss.wav")
  
  If isfullscreen
    OpenScreen(640,480,32,"FPS Trainer")
  Else 
    OpenWindow(0,0,0,640,480,"FPS Trainer",#PB_Window_TitleBar|#PB_Window_SystemMenu|#PB_Window_Maximize|#PB_Window_Minimize|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)  
    OpenWindowedScreen(WindowID(0),0,0,640,480,1,0,0)
  EndIf 
  If 1=1
    LoadSprite(1,"gun.PNG")
    LoadSprite(2,"gunfire.PNG")
    EnableWorldPhysics(1)
    EnableWorldCollisions(1)
    
    WorldShadows(#PB_Shadow_Additive)
    WorldGravity(30)    
    
    AmbientColor(RGB(255,255,255))
    
    CreateMaterial  (0, LoadTexture(0, "Terrain_Texture.jpg"))
    AddMaterialLayer(0, LoadTexture(1, "Terrain_Detail.jpg"), 1)
    
    CreateTerrain("Terrain.png", MaterialID(0), 1,1,1, 4)
    CreateCamera(0, 0, 0, 100, 100)
    CameraLocate(0, 128, 25, 128)
    
    SkyDome("Clouds.jpg",10)    
    
    LoadMesh   (#RobotMesh   , "Robot.mesh")
    LoadTexture(#RobotTexture, "skin.jpg")
    LoadTexture(#RobotTexture+1, "skinhit.jpg")
    
    CreateMaterial(0, TextureID(#RobotTexture))
    CreateMaterial(1, TextureID(#RobotTexture+1))
    
    CreateEntity(#Robot, MeshID(#RobotMesh), MaterialID(0))
    ScaleEntity(#robot,0.1,0.1,0.1)
    SetEntityMass(#robot,69)
    EntityMaterial(#Robot, MaterialID(0))
    EntityLocate(#robot,100,TerrainHeight(100,100),100)
    EntityRenderMode(#robot,#PB_Entity_CastShadow)
    
    EntityPhysicBody(#Robot,#PB_Entity_BoxBody)
    AnimateEntity(#Robot, "Walk")
    
    DisableMaterialLighting(0, 1)
    
    MaterialAmbientColor(0, RGB(100, 100, 100))
    MaterialSpecularColor(0, RGB(255, 255, 255))
    ScrollMaterial(0, 0.15, 0, 1)
        
    CreateLight(0, RGB(0,0,255), 100.0, 0, 0)
    LightSpecularColor(0, RGB(255, 0, 0))
    
    CreateCamera(0, 0, 0, 100, 100)
    CameraLocate(0,scTerSize/2,TerrainHeight(scTerSize/2,scTerSize/2)+10,scTerSize/2)
    CameraLookAt(0,EntityX(#robot),EntityY(#robot),EntityZ(#robot))
    ; CameraBackColor(0, RGB(0, 0, 255))
      
    Repeat
      event=WindowEvent()
      
      
      If setphys
        EnableWorldPhysics(1)
        EntityPhysicBody(#Robot,#PB_Entity_BoxBody)
        SetEntityMass(#robot,69)
        setphys=0
      EndIf 
      ClearScreen(RGB(0, 0, 0))
            
      If ExamineKeyboard()
      
        If KeyboardPushed(#PB_Key_A)
          KeyX = -2
        ElseIf KeyboardPushed(#PB_Key_D)
          KeyX = 2
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_W)
          KeyY = -2
        ElseIf KeyboardPushed(#PB_Key_S)
          KeyY = 2
        Else
          KeyY = 0
        EndIf
                
        If KeyboardPushed(#PB_Key_Add)
          Frame.f+0.005
        EndIf
        
      EndIf
      
      If ExamineMouse()
        MouseX = -MouseDeltaX()/5 
        MouseY = -MouseDeltaY()/5
      EndIf
      
      RotateEntity(#Robot, 1, 0, 0)
      RotateCamera(0, MouseX, MouseY, 0)
      MoveCamera  (0, KeyX, 0, KeyY)
      CameraLocate(0,CameraX(0),TerrainHeight(CameraX(0),CameraZ(0))+10,CameraZ(0))
      
      EntityLocate(#robot,EntityX(#robot)+movex,EntityY(#robot)+movey,EntityZ(#robot)+movez)
            
      If EntityY(#robot)<=TerrainHeight(EntityX(#robot),EntityZ(#robot)) Or prevEX < 0 Or prevEX > scTerSize Or prevEZ < 0 Or prevEZ > scTerSize
        ;EntityLocate(#robot,EntityX(#robot),TerrainHeight(EntityX(#robot),EntityY(#robot)),EntityZ(#robot))
        ex=Random(scTerSize/2)
        ez=Random(scTerSize/2)
        EntityLocate(#robot,ex,TerrainHeight(ex,ez),ez)
        EnableWorldPhysics(0)
        movex.f = Random(100)/100+0.5
        movez.f = Random(100)/100+0.5
        movey.f = Random(100)/100+0.5
        setphys=1
        EntityMaterial(#robot,MaterialID(0))
      EndIf 
      
      RenderWorld()
      
      If MouseButton(1) And mlwasDown=0
        DisplayTransparentSprite(2,0,0) ;fire!
      Else 
        DisplayTransparentSprite(1,0,0) ;normal
      EndIf 
      
      StartDrawing(ScreenOutput())
        DrawingMode(1)
        FrontColor(RGB(255,255,255))
        DrawText(10,10,"Loc: "+Str(CameraX(0))+", "+Str(CameraZ(0)))
        DrawText(10,25,"Fired: "+Str(shotsFired))
        DrawText(10,40,"Hit: "+Str(shotsHit))
        If shotsfired>0
          DrawText(10,55,"Acc%: "+Str((shotsHit/shotsFired)*100.0))
        Else
          DrawText(10,70,"Acc%: n/a")
        EndIf 
        DrawText(10,85,"Time: "+Str((ElapsedMilliseconds()-startms)/1000)+" s")
      StopDrawing()
      
      FlipBuffers()
      
      If MouseButton(1) And mlwasDown=0
        GrabSprite(3,295,215,50,50)
        StartDrawing(SpriteOutput(3))
        shotsfired+1
        For i = 23 To 27
          For j = 23 To 27
            p=Point(i,j)
            If Red(p)>230 And Green(p)<10 And Blue(p)<10
              EntityMaterial(#robot,MaterialID(1))
              hitStr.s="H"
              PlaySound(0)
              Break 
            EndIf 
          Next 
        Next 
        DrawingMode(#PB_2DDrawing_Outlined)
        Box(22,22,6,6,RGB(0,255,0))
        StopDrawing()
        
        If hitStr="H"
          shotshit+1
        Else
          PlaySound(1)
        EndIf 
        
        If shotsfired=1
          CreateDirectory("./"+sessionFolder)
        EndIf 
        SaveSprite(3,"./"+sessionFolder+"/shot"+Str(shotsFired)+hitStr.s+".png")
        hitStr.s = ""
        mlwasDown=1
      EndIf         
      
      If MouseButton(1)
        mLwasdown=1
      Else 
        mLwasdown=0
      EndIf 
      
      prevEX = EntityX(#robot)
      prevEY = EntityY(#robot)
      prevEZ = EntityZ(#robot)
      
      If (ElapsedMilliseconds()-startms)/1000 >= maxTime And maxtime>0
        Quit=1
      EndIf 
      
      Delay(10) ;60+fps
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
    
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
If shotsfired>0  
  fid=CreateFile(#PB_Any,"./"+sessionFolder+"/stats.log")
  If fid<>0
    WriteStringN(fid,"Fired: "+Str(shotsFired))
    WriteStringN(fid,"Hit: "+Str(shotsHit))
    WriteStringN(fid,"Acc%: "+Str((shotsHit/shotsFired)*100.0))
    WriteStringN(fid,"Time (s): "+Str((ElapsedMilliseconds()-startms)/1000))
    CloseFile(fid)
  EndIf
EndIf 
 
End
; IDE Options = PureBasic v4.02 (Windows - x86)
; CursorPosition = 229
; FirstLine = 199
; Folding = -
; Executable = FPSTrainer.exe
; DisableDebugger
					Last edited by dracflamloc on Sun Oct 07, 2007 10:05 pm, edited 1 time in total.
									
			
									
						- Kaeru Gaman
 - Addict

 - Posts: 4826
 - Joined: Sun Mar 19, 2006 1:57 pm
 - Location: Germany
 
2 drac
Thanks! I will directly change 2, 3 lines and sell it!
>> It's really good to encourage using Ogre. I'm searching to pitch movements. But I didn't find X, Y and Z rotation values with the misc handles available. It could be certainly a simple calcul, like a cardan' rotation simulation.
I ask you the source too in order to know if there is many architectures of main loop with native statements. If there is only one, my 3D game' editor is in the good way! (Opensource, comme d'hab)
			
			
									
									
						Thanks! I will directly change 2, 3 lines and sell it!
>> It's really good to encourage using Ogre. I'm searching to pitch movements. But I didn't find X, Y and Z rotation values with the misc handles available. It could be certainly a simple calcul, like a cardan' rotation simulation.
I ask you the source too in order to know if there is many architectures of main loop with native statements. If there is only one, my 3D game' editor is in the good way! (Opensource, comme d'hab)
@drac
I changed sound and keys (Why not key arrows?). I hope you won't kill me...
Tschüss!
			
			
													I changed sound and keys (Why not key arrows?). I hope you won't kill me...
Tschüss!
Code: Select all
;FPSTrainer - Copyright 2007 DracSoft - License: GNU GPL (www.gnu.org) 
;3D engine : OGRE. License : See www.ogre3d.org
;FPSTrainer - Copyright 2007 DracSoft - License: GNU GPL (www.gnu.org) 
;3D engine : OGRE. License : See www.ogre3d.org 
Global m_hMidiOut,m_MIDIOpen.b 
Procedure SendMIDIMessage(nStatus.l,nCanal.l,nData1.l,nData2.l) 
  dwFlags.l = nStatus | nCanal | (nData1 << 8 ) | (nData2 << 16) 
  temp.l = midiOutShortMsg_ (m_hMidiOut,dwFlags) ; 
   If temp<>0 
     MessageRequester ( "Problème" , "Erreur dans l'envoi du message MIDI" ,0) 
   EndIf 
EndProcedure 
Procedure MIDIOpen() 
   If m_MIDIOpen = 0 
     If midiOutOpen_ (@m_hMidiOut,MIDIMAPPER,0,0,0) <> 0 
       MessageRequester ( "Problème" , "Impossible d'ouvrir le périphérique MIDI" ,0) 
     Else 
      SendMIDIMessage($C0,0,0,0) 
      m_MIDIOpen = 1 
     EndIf 
   EndIf 
EndProcedure 
Procedure PlayNoteMIDI(Canal.b,Note.b,VelociteDown.b,VelociteUp.b) 
   If m_MIDIOpen 
    SendMIDIMessage($80 | Canal,0,Note,VelociteDown) 
    SendMIDIMessage($90 | Canal,0,Note,VelociteUp) 
   EndIf 
EndProcedure 
Procedure ChargeInstrument(Canal.b,Instrument.b) 
   If m_MIDIOpen 
    SendMIDIMessage($C0 | Canal,0,Instrument,0) 
   EndIf 
EndProcedure 
MIDIOpen() 
ChargeInstrument(0,127) ; canal , instrument 
;FPSTrainer - Copyright 2007 DracSoft 
;todo - 'session log' of screenshots of every shot fired in a datetimed directory 
;todo - 'onscreen accuraccy + totals 
Define.f KeyX, KeyY, MouseX, MouseY 
#RobotMesh    = 90 
#RobotTexture = 90 
#Robot        = 90 
movex.f = Random(100)/100+0.5 
movez.f = Random(100)/100+0.5 
movey.f = Random(100)/100+0.5 
scTerSize = 1024 
mLwasdown = 0 
isfullscreen=Val(ProgramParameter()) 
maxTime = Val(ProgramParameter())  
startMs = ElapsedMilliseconds() 
shotsFired.f=0 
shotsHit.f=0 
shotCounter=0 
sessionFolder.s=Str(Year(Date()))+"-"+Str(Month(Date()))+"-"+Str(Day(Date()))+" "+Str(Date()) 
  
If InitEngine3D() 
  Add3DArchive("E:\FPS\", #PB_3DArchive_FileSystem) 
  
  InitSound() 
  InitSprite() 
  UsePNGImageDecoder() 
  UsePNGImageEncoder() 
  UseOGGSoundDecoder() 
  InitKeyboard() 
  InitMouse() 
  
;  LoadSound(0,"./hit.ogg") 
;  LoadSound(1,"./miss.wav") 
  
  If isfullscreen 
    OpenScreen(640,480,32,"FPS Trainer") 
  Else 
    OpenWindow(0,0,0,640,480,"FPS Trainer",#PB_Window_TitleBar|#PB_Window_SystemMenu|#PB_Window_Maximize|#PB_Window_Minimize|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)  
    OpenWindowedScreen(WindowID(0),0,0,640,480,1,0,0) 
  EndIf 
  If 1=1 
    LoadSprite(1,"E:\FPS\gun.PNG") 
    LoadSprite(2,"E:\FPS\gunfire.PNG") 
    EnableWorldPhysics(1) 
    EnableWorldCollisions(1) 
    
    WorldShadows(#PB_Shadow_Additive) 
    WorldGravity(30)    
    
    AmbientColor(RGB(255,255,255)) 
    
    CreateMaterial  (0, LoadTexture(0, "Terrain_Texture.jpg")) 
    AddMaterialLayer(0, LoadTexture(1, "Terrain_Detail.jpg"), 1) 
    
    CreateTerrain("Terrain.png", MaterialID(0), 1,1,1, 4) 
    CreateCamera(0, 0, 0, 100, 100) 
    CameraLocate(0, 128, 25, 128) 
    
    SkyDome("Clouds.jpg",10)    
    
    LoadMesh   (#RobotMesh   , "Robot.mesh") 
    LoadTexture(#RobotTexture, "skin.jpg") 
    LoadTexture(#RobotTexture+1, "skinhit.jpg") 
    
    CreateMaterial(0, TextureID(#RobotTexture)) 
    CreateMaterial(1, TextureID(#RobotTexture+1)) 
    
    CreateEntity(#Robot, MeshID(#RobotMesh), MaterialID(0)) 
    ScaleEntity(#robot,0.1,0.1,0.1) 
    SetEntityMass(#robot,69) 
    EntityMaterial(#Robot, MaterialID(0)) 
    EntityLocate(#robot,100,TerrainHeight(100,100),100) 
    EntityRenderMode(#robot,#PB_Entity_CastShadow) 
    
    EntityPhysicBody(#Robot,#PB_Entity_BoxBody) 
    AnimateEntity(#Robot, "Walk") 
    
    DisableMaterialLighting(0, 1) 
    
    MaterialAmbientColor(0, RGB(100, 100, 100)) 
    MaterialSpecularColor(0, RGB(255, 255, 255)) 
    ScrollMaterial(0, 0.15, 0, 1) 
        
    CreateLight(0, RGB(0,0,255), 100.0, 0, 0) 
    LightSpecularColor(0, RGB(255, 0, 0)) 
    
    CreateCamera(0, 0, 0, 100, 100) 
    CameraLocate(0,scTerSize/2,TerrainHeight(scTerSize/2,scTerSize/2)+10,scTerSize/2) 
    CameraLookAt(0,EntityX(#robot),EntityY(#robot),EntityZ(#robot)) 
    ; CameraBackColor(0, RGB(0, 0, 255)) 
      
    Repeat 
      event=WindowEvent() 
      
      
      If setphys 
        EnableWorldPhysics(1) 
        EntityPhysicBody(#Robot,#PB_Entity_BoxBody) 
        SetEntityMass(#robot,69) 
        setphys=0 
      EndIf 
      ClearScreen(RGB(0, 0, 0)) 
            
      If ExamineKeyboard() 
      
        If KeyboardPushed(#PB_Key_Left) 
          KeyX = -2 
        ElseIf KeyboardPushed(#PB_Key_Right) 
          KeyX = 2 
        Else 
          KeyX = 0 
        EndIf 
        
        If KeyboardPushed(#PB_Key_Up) 
          KeyY = -2 
        ElseIf KeyboardPushed(#PB_Key_Down) 
          KeyY = 2 
        Else 
          KeyY = 0 
        EndIf 
                
        If KeyboardPushed(#PB_Key_Add) 
          Frame.f+0.005 
        EndIf 
        
      EndIf 
      
      If ExamineMouse() 
        MouseX = -MouseDeltaX()/5 
        MouseY = -MouseDeltaY()/5 
      EndIf 
      
      RotateEntity(#Robot, 1, 0, 0) 
      RotateCamera(0, MouseX, MouseY, 0) 
      MoveCamera  (0, KeyX, 0, KeyY) 
      CameraLocate(0,CameraX(0),TerrainHeight(CameraX(0),CameraZ(0))+10,CameraZ(0)) 
      
      EntityLocate(#robot,EntityX(#robot)+movex,EntityY(#robot)+movey,EntityZ(#robot)+movez) 
            
      If EntityY(#robot)<=TerrainHeight(EntityX(#robot),EntityZ(#robot)) Or prevEX < 0 Or prevEX > scTerSize Or prevEZ < 0 Or prevEZ > scTerSize 
        ;EntityLocate(#robot,EntityX(#robot),TerrainHeight(EntityX(#robot),EntityY(#robot)),EntityZ(#robot)) 
        ex=Random(scTerSize/2) 
        ez=Random(scTerSize/2) 
        EntityLocate(#robot,ex,TerrainHeight(ex,ez),ez) 
        EnableWorldPhysics(0) 
        movex.f = Random(100)/100+0.5 
        movez.f = Random(100)/100+0.5 
        movey.f = Random(100)/100+0.5 
        setphys=1 
        EntityMaterial(#robot,MaterialID(0)) 
      EndIf 
      
      RenderWorld() 
      
      If MouseButton(1) And mlwasDown=0 
        DisplayTransparentSprite(2,0,0) ;fire! 
      Else 
        DisplayTransparentSprite(1,0,0) ;normal 
      EndIf 
      
      StartDrawing(ScreenOutput()) 
        DrawingMode(1) 
        FrontColor(RGB(255,255,255)) 
        DrawText(10,10,"Loc: "+Str(CameraX(0))+", "+Str(CameraZ(0))) 
        DrawText(10,25,"Fired: "+Str(shotsFired)) 
        DrawText(10,40,"Hit: "+Str(shotsHit)) 
        If shotsfired>0 
          DrawText(10,55,"Acc%: "+Str((shotsHit/shotsFired)*100.0)) 
        Else 
          DrawText(10,70,"Acc%: n/a") 
        EndIf 
        DrawText(10,85,"Time: "+Str((ElapsedMilliseconds()-startms)/1000)+" s") 
      StopDrawing() 
      
      FlipBuffers() 
      
      If MouseButton(1) And mlwasDown=0 
        GrabSprite(3,295,215,50,50) 
        StartDrawing(SpriteOutput(3)) 
        shotsfired+1 
        For i = 23 To 27 
          For j = 23 To 27 
            p=Point(i,j) 
            If Red(p)>230 And Green(p)<10 And Blue(p)<10 
              EntityMaterial(#robot,MaterialID(1)) 
              hitStr.s="H" 
              PlayNoteMIDI(0,50, 127, 80) 
              Break 
            EndIf 
          Next 
        Next 
        DrawingMode(#PB_2DDrawing_Outlined) 
        Box(22,22,6,6,RGB(0,255,0)) 
        StopDrawing() 
        
        If hitStr="H" 
          shotshit+1 
        Else 
          PlayNoteMIDI(0,50, 127, 80) 
        EndIf 
        
        hitStr.s = "" 
        mlwasDown=1 
      EndIf          
      
      If MouseButton(1) 
        mLwasdown=1 
      Else 
        mLwasdown=0 
      EndIf 
      
      prevEX = EntityX(#robot) 
      prevEY = EntityY(#robot) 
      prevEZ = EntityZ(#robot) 
      
      If (ElapsedMilliseconds()-startms)/1000 >= maxTime And maxtime>0 
        Quit=1 
      EndIf 
      
      Delay(10) ;60+fps 
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1 
  EndIf 
    
Else 
  MessageRequester("Error", "The 3D Engine can't be initialized",0) 
EndIf 
  
End 
					Last edited by Ollivier on Wed Oct 10, 2007 3:56 am, edited 4 times in total.
									
			
									
						- 
				dracflamloc
 - Addict

 - Posts: 1648
 - Joined: Mon Sep 20, 2004 3:52 pm
 - Contact:
 

