What is wrong with this?

Advanced game related topics
jannepelaa
New User
New User
Posts: 3
Joined: Wed Oct 25, 2006 5:27 pm
Location: The Earth

What is wrong with this?

Post by jannepelaa »

Why the player are moving whitout reason?

Code: Select all

#CameraSpeed = 0.5

IncludeFile "Screen3DRequester.pb"

OpenWindow(0, 0, 0, 1280, 1024, "Mauno Theft Auto III", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

Define.f KeyX, KeyY, MouseX, MouseY, kulma

If InitEngine3D()
  Add3DArchive("Data\"          , #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()

    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)

    CreateMaterial(0, LoadTexture(0, "r2skin.jpg"))
    CreateEntity(0, LoadMesh(0, "robot.mesh"), MaterialID(0))
    AnimateEntity(0, "Walk")
    ScaleEntity(0,0.2,0.2,0.2)

    
    CreateCamera(0, 0, 0, 100, 100)  ; Front camera
    CameraLocate(0,0,0,100)
    RotateCamera(0,270,0,0)
    
 
    
    SkyDome("Clouds.jpg",10)
    
    Repeat
      Screen3DEvents()
            
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed
           
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed 
           
        Else
          KeyX = 0
          If KeyboardPushed(#PB_Key_Up)=0 And KeyboardPushed(#PB_Key_Down)=0
             SetEntityAnimationTime(0, 5.12)
             
          EndIf    
        EndIf
                  
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed 
          
           
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed
           
            
        Else
          KeyY = 0
          If KeyboardPushed(#PB_Key_Left)=0 And KeyboardPushed(#PB_Key_Right)=0
              SetEntityAnimationTime(0, 5.12)
          EndIf    
        EndIf
        
        


      EndIf
      
      If ExamineMouse()
        MouseX = -(MouseDeltaX()/1);*0.5
        MouseY = -(MouseDeltaY()/1);*0.5
        
        
      EndIf
      
      kulma23.f=kulma.f
      
      If kulma23.f > 360 
         kulma23.f=kulma23.f-360
      EndIf 
      
      kulma.f=kulma.f+mousex
      
      RotateEntity (0, kulma, 0, 0)
              EntityLocate(0, CameraX(0), CameraY(0)-18, CameraZ(0))
        
      
      RotateCamera(0, 0, MouseY, 0)
      
      Height.f = TerrainHeight(EntityX(0), EntityZ(0))
      
      EntityLocate  (0,EntityX(0) , Height+38, EntityZ(0))
          
      MoveEntity (0,keyx,0,keyy)    
       

       
      kulma2.f=kulma.f*moovaus.f   
      kulma2.f= -kulma.f* 3.14159265358979/180    
      
      x=Cos(kulma2.f)*30;Tan(kulma2.f)*15
      z=Sin(kulma2.f)*30;Cos(kulma2.f)*15
      
      
      ;MoveEntity (0,mousex,0,0)
      
      oldx=EntityX(0)  
      oldy=EntityZ(0)      
   
      CameraLocate(0,EntityX(0)-x,EntityY(0)+18,EntityZ(0)-z)  
      
      
      
       
      
      CameraLookAt(0, EntityX(0), -MouseY()+200, EntityZ(0))
            
      RenderWorld()
      Screen3DStats()
      FlipBuffers()
      

      
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
    
Else
  MessageRequester("Error!", "The 3D Engine can't be initialized",0)
EndIf
  
End
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Too many files missing and I'm too lazy to replace them all. Please just provide the fraction of code that causes the problem.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
GBeebe
Enthusiast
Enthusiast
Posts: 263
Joined: Sat Oct 09, 2004 6:52 pm
Location: Franklin, PA - USA
Contact:

Works fine here.

Post by GBeebe »

I coppied you code exactly how you have it and the robot only moves when i press an arrow key, and stop when i release it... perhaps something is wrong with your keyboard?
jannepelaa
New User
New User
Posts: 3
Joined: Wed Oct 25, 2006 5:27 pm
Location: The Earth

Post by jannepelaa »

What? In my case that keeps moving! But etc. Battlefield 2 works!

Edit: Do you change the code?
thamarok
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 06, 2006 1:37 pm

Post by thamarok »

jannepelaa wrote:What? In my case that keeps moving! But etc. Battlefield 2 works!

Edit: Do you change the code?
Hi!
I tested your code and it seems to work ok.

Janne, mä uskoisin että puhut suomea. Koitin koodiasi ja se toimi niin kuin pitäisi. Mikä tässä mättää?
jannepelaa
New User
New User
Posts: 3
Joined: Wed Oct 25, 2006 5:27 pm
Location: The Earth

Post by jannepelaa »

No Suomeksi:

En paina mitään mutta pelaaja kumminkin liikkuu kokoajan, näppäimien painelukaan ei auta! :(

No yritän sitten hankkia uuden näppäimistön?

Sorry, that was finnish! :oops:
Post Reply