Jump to content
  • Advertisement
Sign in to follow this  
Moonboy333

Blitz3d help

This topic is 3789 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello Everyone! I tried posting this on a different section of this forum 3 days ago. I haven't gotten any replies and I can't really move on untill I get the basics down. I am trying to get a basic FPS style movement/looking system. I have to movement rotation, gravity and collisions all in but here are my problems: 1.If I look up and then hit the forward button, I move up. I tried changing the forward and backward controls from TranslateEntity to Moveentity. 2. I need help with the jumping system. How can I make it so you can only jump once until you hit the ground. How do I make the jump smooth as well. 3. I use blender for my 3d models but i can't import them into blitz What is another easy 3d program that is free but powerful that i could use 4. Gravity tips also welcome Here is my complete code: -------------------------------------------------------------------------------- Graphics3D 1024, 768 SetBuffer BackBuffer() ;Collisions type_camera=1 type_ground=2 ;Create Cameras camera=CreateCamera() PositionEntity camera, 0,5,5 RotateEntity camera, 0,0,0 EntityType camera,type_camera EntityRadius camera, 4 ;Lights light1=CreateLight() ;Create Terrain plane=CreatePlane() PositionEntity plane,0,0,0 tex=LoadTexture("landscape-rocky.jpg") ScaleTexture tex, 100,100 EntityTexture plane, tex EntityType plane,type_ground ;objects cube1=CreateCube() PositionEntity cube1,0,5,5 cube2=CreateCube() PositionEntity cube2,0,5,-5 ;Collision Calling Collisions type_camera,type_ground,2,2 ;Exit Sequence (take out for final game) While Not KeyDown(1) ;Movements ; Player 1 If KeyDown(17) MoveEntity camera,0,0,1 If KeyDown(31) MoveEntity camera,0,0,-1 If KeyDown(32) MoveEntity camera,1,0,0 If KeyDown(30) MoveEntity camera,-1,0,0 If KeyDown(57) MoveEntity camera,0,3,0 If KeyDown(22) pitch#=pitch#-1 If KeyDown(36) pitch#=pitch#+1 If KeyDown(35) yaw#=yaw#+1 If KeyDown(37) yaw#=yaw#-1 RotateEntity camera,pitch#,yaw#,roll# TranslateEntity camera, 0,-.5,0 UpdateWorld RenderWorld Flip Wend End -------------------------------------------------------------------------------- Any help would be appreciated Thanks! Peter PS Ignore the cubes, they were there from a previous experiment. You also need to use your own texture for the ground.

Share this post


Link to post
Share on other sites
Advertisement
sorry please ignore this thread!
I made a mistake and have decided to ditch Blitz because it can't do what I want as well as other programs. Sorry

Share this post


Link to post
Share on other sites
Heres some fps code i knocked up this morning.

Blitz3d is quite capable of creating fps games.

The code below doesn't require any media. Just copy and paste into the blitz3d ide and compile and run.




graphics3d 1024,768,32

setbuffer backbuffer()

light = CreateLight()

Plane = CreatePlane()
PlaneTexture = CreateTexture(128,128,9)
ClsColor 0,200,80
Cls
Color 255,255,255
Rect 0,0,64,64,1
Rect 64,64,64,64,1
CopyRect 0,0,128,128,0,0,BackBuffer(),TextureBuffer(PlaneTexture)
ScaleTexture PlaneTexture,20,20
EntityTexture Plane,PlaneTexture,0,0


global mouse_y_amount#
global mouse_x_amount#



camera = CreateCamera()
camerazoom camera,1.65
positionentity camera,0,10,0

global camera_x_pos# = 0
global camera_y_pos# = 0
global camera_z_pos# = 0



global dir_vec_x# = 0
global dir_vec_z# = 0

global dir_vec_x_1# = 0
global dir_vec_z_1# = 0


global camera_rotation_x_velocity# = 0
global camera_rotation_y_velocity# = 0

global camera_movement_x_velocity# = 0
global camera_movement_z_velocity# = 0


frameTimer = CreateTimer(60)

global camera_pitch#





;main loop
While keydown(1) = false

WaitTimer(frameTimer) ; limit to 60 fps



;read mouse
mouse_y_amount# = MouseYSpeed()
mouse_x_amount# = MouseXSpeed()

mouse_x_amount# = mouse_x_amount# / 100 ; value of 100 is to scale mouse movemnt.
mouse_y_amount# = mouse_y_amount# / 100
MoveMouse 1024 / 2 , 768 /2 ; move mouse cursor back to the screen centre






forward_speed# = 0
if keydown(200) = true then forward_speed# = 0.1
if keydown(208) = true then forward_speed# = -0.1

;calculate forward movement vector
angle# = entityyaw#(camera)
s# = sin(angle#)
c# = cos(angle#)

dir_vec_x# = 0
dir_vec_z# = 1

dir_vec_x_1# = (dir_vec_x# * c#) + (dir_vec_z# * -s)
dir_vec_z_1# = (dir_vec_x# * s#) + (dir_vec_z# * c)

dir_vec_x_1# = dir_vec_x_1# * forward_speed#
dir_vec_z_1# = dir_vec_z_1# * forward_speed#

camera_movement_x_velocity# = camera_movement_x_velocity# + dir_vec_x_1#
camera_movement_z_velocity# = camera_movement_z_velocity# + dir_vec_z_1#






sideways_speed# = 0
if keydown(203) = true then sideways_speed# = 0.1
if keydown(205) = true then sideways_speed# = -0.1


;calculate strafe movement vector
angle# = entityyaw#(camera) + 90


s# = sin(angle#)
c# = cos(angle#)

dir_vec_x# = 0
dir_vec_z# = 1

dir_vec_x_1# = (dir_vec_x# * c#) + (dir_vec_z# * -s)
dir_vec_z_1# = (dir_vec_x# * s#) + (dir_vec_z# * c)

dir_vec_x_1# = dir_vec_x_1# * sideways_speed#
dir_vec_z_1# = dir_vec_z_1# * sideways_speed#

camera_movement_x_velocity# = camera_movement_x_velocity# + dir_vec_x_1#
camera_movement_z_velocity# = camera_movement_z_velocity# + dir_vec_z_1#




;update smooth camera rotation
camera_rotation_x_velocity# = camera_rotation_x_velocity# + mouse_x_amount#
camera_rotation_y_velocity# = camera_rotation_y_velocity# + mouse_y_amount#

;limit camera pitch
camera_pitch# = entitypitch#(camera)
if camera_pitch# > 80 then camera_pitch# = 80
if camera_pitch# < -80 then camera_pitch# = -80

;update camera orientation by adding camera orientation velocites
rotateentity camera , camera_pitch# , entityyaw#(camera) , 0
turnEntity camera , camera_rotation_y_velocity# , -camera_rotation_x_velocity# , 0


;update cameras position by adding the velocity vectors
camera_x_pos# = camera_x_pos# + camera_movement_x_velocity#
camera_z_pos# = camera_z_pos# + camera_movement_z_velocity#

PositionEntity camera, camera_x_pos# , 10 , camera_z_pos#


;add friction to velocities
camera_rotation_x_velocity# = camera_rotation_x_velocity# * 0.95
camera_rotation_y_velocity# = camera_rotation_y_velocity# * 0.95

camera_movement_x_velocity# = camera_movement_x_velocity# * 0.95
camera_movement_z_velocity# = camera_movement_z_velocity# * 0.95

;update display
RenderWorld
Flip

Wend



This code doesn't allow for walking over a terrain or floor, or allow for wall collisions, but they should be easily implemented using the linepick command.

KJM

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!