Jump to content

Canardia

Developers
  • Posts

    4,127
  • Joined

  • Last visited

Posts posted by Canardia

  1. The missing classname key is a bit problematic in 2.3, since you have to take some random other key to identify the class. You could also set some custom entity key with Notepad++ in the sbx file, for example class_name="light_directional", but of course it would be nicer to have that functionality in Editor.

     

    It could be also fixed with a complete new LUA script set for all default entities of LE, so that each LUA script provides a classname field where the user can enter the class name. Maybe I will do that for gamelib, and include modified versions of all lights and other default entities with gamelib.

  2. The benefit is not exactly nothing, since BlitzMax users also need sometimes to use other languages. Most commercial games are using several 3rd party libraries, and you don't find them for BlitzMax. For example Far Cry 2 had a huge list of 3rd party libraries. If any of such 3rd party libraries then need to access LE, Lua or framework, you will need to use engine.dll. Also the upcoming DLL version of GameLib will have the same need.

  3. Because it's part of the engine now, not a seperate product. You don't put the company "logo" more than once into a product, so Leadwerks Engine covers already that :) It's also less visible now, since all framework commands appear like plain commands and not using any visible reference to framework (except for a few, and in Lua).

  4. Putting additional game core related entities to a Editor scene is also not the optimal solution. Then all those additional entities would be needed to be present in all scenes. That's redundant and allows unique information to be corrupted (as the same information should be present in all scenes).

    Of course this problem is raised by Editor itself, since it doesn't utilize a "common scene" and the "actual scene" concept. The "common scene" would contain all entities which are common in all scenes (for a specific project).

    However, there is a indirect solution for this problem: You could have a "common scene reference" entity, which would then load the common scene, and all its contained entities.

     

    Another solution would be to rewrite Editor to use sqlite databases instead of sbx files :(

  5. Let's start improving this with the options like screen resolution and which map to load.

    The first thing which comes to my mind would be reading a fpscontroller2.ini file from disk with LUA.

    Then there could be a fpscontroller2config.lua which would launch an UI where the user can select the options.

    It could be also part of fpscontroller2.lua, but then there would need to be a title screen where you can choose to play the game or to configure the settings.

     

    I'm not sure how your GAME_MODE idea works, because then it should support all kind of game types. I think it's easier to make a seperate lua file for each game type (at least in the beginning).

  6. Yeah, I though also of making fpscontroller using some classes, but this is just the first working version with Engine.exe.

    I noticed that emitters don't work, and that the skybox is loaded although it should not. Must be a bug in Engine.exe :lol:

  7. You can use this fpscontroller2.lua from Editor or by dragging it over Engine.exe.

    --stuff which should be part of LE
    
    --the best working round function, works also for negative idp (written by Robert Jay Gould)
    function round(num, idp)
    return tonumber(string.format("%." .. (idp or 0) .. "f", num))
    end
    
    BLEND_NONE=0
    BLEND_ALPHA=1
    
    --end of stuff which should be part of LE
    
    if fw==nil then --we are not in Editor
    RegisterAbstractPath("")
    Graphics(800,600)
    fw=CreateFramework()
    scene=LoadScene("abstract::tunnels.sbx")
    scene:SetCollisionType(COLLISION_SCENE)
    TFilter(1)
    AFilter(4)
    standalone=1
    end
    
    require("Scripts/constants/collision_const")
    require("Scripts/constants/engine_const")
    require("Scripts/LinkedList")
    require("Scripts/filesystem")
    require("Scripts/math/math")
    require("scripts/classes/bullet")
    
    --Variables
    dx=0.0
    dy=0.0
    camerapitch=0.0
    camerayaw=0.0
    move=0.0
    strafe=0.0
    
    --Create a player controller
    controller=CreateController(1.8,0.45,0.25,45)
    controller:SetCollisionType(COLLISION_CHARACTER,0)
    controller:SetMass(10)
    if standalone==1 then
    controller:SetPosition(Vec3(38.8,5.7,7))
    else
    controller:SetPosition(fw.main.camera.position)
    end
    camerapitch=fw.main.camera.rotation.x
    camerayaw=fw.main.camera.rotation.y+180
    
    local gunscale=0.6
    local vwep = LoadMesh("abstract::vwep_hands.gmf")
    LoadMesh("abstract::vwep_gun.gmf",vwep)
    vwep:SetParent(fw.main.camera,0)
    vwep:SetPosition(Vec3(-0.18*gunscale,-0.03*gunscale,0.37*gunscale),0)
    vwep:SetScale(Vec3(0.04*gunscale,0.04*gunscale,0.04*gunscale))
    local gundisplayposition = vwep:GetPosition()
    sound_gunshot = LoadSound("abstract::gunshot.ogg")
    source_gunshot = CreateSource(sound_gunshot)
    source_gunshot:SetVolume(0.5)
    vwep :SetShadowMode(0,1)
    local displayposition=Vec3(-0.26/2.0,-0.03,0.19)
    local muzzleflash = CreatePointLight(3)
    muzzleflash:SetParent( vwep )
    muzzleflash:SetColor(Vec4(1,0.6,0.0,1.0))
    muzzleflash:SetPosition( displayposition )
    muzzleflash:SetShadowMode(0)
    
    HideMouse()
    MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2)
    FlushKeys()
    FlushMouse()
    
    local pick
    local camera = fw.main.camera
    local remainingtime
    local starttime=AppTime()
    local gameduration=2--length of game in minutes
    local gamemode=0
    
    gunpos = vwep.position:Copy()
    
    local smoothedgunswayamplitude=0.0
    local smoothedgunswayspeed	=0.0
    local guntime = 0.0
    local recoil = 0.0
    local lastfiretime=0.0
    local smoothrecoil=0.0
    local swaydamping=0.0
    local smoothswaydamping=0.0
    local lightsmoothing =0.0
    local gunlight = 0.0
    
    --Flashlight
    flashlight = {}
    flashlight.light = CreateSpotLight(8)
    flashlight.light:Hide()
    flashlight.sound_switch = LoadSound("abstract::switch.wav")
    flashlight.state=0
    flashlight.light:SetConeAngles(30,35)
    flashlight.light:SetRotation(Vec3(5,0,0))
    flashlight.light:SetShadowmapSize(512)
    flashlight.light:Paint(LoadMaterial("abstract::flashlight.mat"))
    
    function flashlight:SetState( state )
    if state~=self.state then
    	self.state=state
    	if state==0 then
    		self.light:Hide()
    	else
    		self.light:Show()
    	end
    	if self.sound_switch~=nil then
    		self.sound_switch:Play()
    	end
    end
    end
    
    
    function ShootBullet( position, direction )
    --	local speed=100.0
    --	local pick = LinePick( position, Vec3(position.x+direction.x * speed) )
    end
    
    
    function DrawHUD(contr)
    SetBlend(BLEND_ALPHA)
    DrawText("pos: "..round(contr.position.x,3)..","..round(contr.position.y,3)..","..round(contr.position.z,3),1,FontHeight()*5)
    DrawText("rot: "..round(contr.rotation.x,3)..","..round(contr.rotation.y,3)..","..round(contr.rotation.z,3),1,FontHeight()*6)
    SetBlend(BLEND_NONE)
    end
    
    
    --main function
    while KeyHit(KEY_ESCAPE)==0 do
    jump=KeyHit(KEY_SPACE)*6.0
    if controller:IsAirborne()==1 then jump=0 end
    
    
    local time = AppTime()/3200.0
    local frame = time*(179.0-96.0)+96.0
    frame=Clamp( frame, 96, 179 )
    vwep:Animate(96,1,0,1)
    
    
    --Camera look
    gx=Round(GraphicsWidth()/2)
    gy=Round(GraphicsHeight()/2)
    dx=Curve((MouseX()-gx)/4.0,dx,3.0/AppSpeed())
    dy=Curve((MouseY()-gy)/4.0,dy,3.0/AppSpeed())
    MoveMouse(gx,gy)
    camerapitch=camerapitch+dy
    camerayaw=camerayaw-dx
    camerapitch=math.min(camerapitch,90)
    camerapitch=math.max(camerapitch,-90)
    fw.main.camera:SetRotationf(camerapitch,camerayaw,0,1)
    
    movespeed=6
    movesmoothing=10
    if controller:IsAirborne()==1 then
    	movesmoothing=200
    end
    
    --Player movement
    move=Curve( (KeyDown(KEY_W)-KeyDown(KEY_S))*movespeed,move,movesmoothing)
    strafe=Curve( (KeyDown(KEY_D)-KeyDown(KEY_A))*movespeed,strafe,movesmoothing)
    
    --Use objects
    if KeyHit(KEY_E)==1 then
    	pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0)
    	if pick~=nil then
    		repeat
    			if pick.entity:GetClass()==ENTITY_MODEL then
    				break
    			end
    			pick.entity=pick.entity.parent
    		until pick.entity==nil
    		if pick.entity~=nil then
    			pick.entity:SendMessage("use",controller,0)
    		end
    	end
    end
    
    --Update controller
    controller:Update(camerayaw,move,strafe,jump,40,10)
    
    fw:Update()
    
    if KeyHit(KEY_F)==1 then
    	flashlight:SetState(1-flashlight.state)
    end
    
    --Position camera
    camera:SetPositionf(controller.position.x,controller.position.y+0.8,controller.position.z,1)
    
    time=AppTime()
    gunfirefrequency=80
    gunswayspeed=0.001*20.0
    gunoffset = gunpos:Copy()
    gunswayamplitude = 0.02
    if KeyDown(KEY_W)==1 or KeyDown(KEY_D)==1 or KeyDown(KEY_A)==1 or KeyDown(KEY_S)==1 then
    	gunswayamplitude = 0.03
    	gunswayspeed=0.005*20.0
    end
    smoothedgunswayamplitude = Curve( gunswayamplitude, smoothedgunswayamplitude,8.0  )
    smoothedgunswayspeed = Curve( gunswayspeed, smoothedgunswayspeed,8.0 )
    if smoothrecoil<0.001 then
    	guntime = guntime + AppSpeed() * smoothedgunswayspeed * math.max(0.0,1.0 - smoothswaydamping)
    end
    gunoffset.z = gunoffset.z - smoothrecoil * 0.05
    --smoothedgunswayamplitude = smoothedgunswayamplitude * (1.0 - smoothswaydamping)
    gunoffset.x = gunoffset.x + math.sin( guntime ) * smoothedgunswayamplitude * gunscale
    gunoffset.y = gunoffset.y + (1.0-math.cos( guntime*2.0 )) * 0.005 * gunscale-- * math.min(1.0,1.0 - smoothswaydamping))
    vwep:SetPosition( gunoffset )
    recoil = recoil-0.1
    swaydamping = math.max( swaydamping - 0.05, 0.0 )
    recoil = math.max(recoil,0.0)
    smoothrecoil=Curve(recoil,smoothrecoil,3.0)
    smoothswaydamping = Inc( swaydamping ,smoothswaydamping,0.01 )
    gunlight = math.max( gunlight- 0.2, 0.0 )
    lightsmoothing =gunlight-- Curve(gunlight,lightsmoothing,8.0)
    muzzleflash:SetColor(Vec4(1.0*lightsmoothing,0.6*lightsmoothing,0.0,1.0))
    if lightsmoothing <0.01 then
    	muzzleflash:Hide()
    end
    if MouseDown(1)==1 then
    	if AppTime()-lastfiretime>gunfirefrequency then
    		recoil = 1.0
    		lastfiretime=AppTime()+math.random(0,20)
    		gunswayspeed=0.0
    		gunlight = 1.0
    		source_gunshot:Play()
    		source_gunshot:SetPitch(1.0 + (math.random()-0.5)*0.05 )
    		swaydamping = 1.0
    		muzzleflash:Show()
    
    		CreateBullet(vwep:GetPosition(1) , fw.main.camera.mat:K():Scale(300))
    
    	end
    end
    
    UpdateBullets()
    
    flashlight.light:SetPosition(fw.main.camera:GetPosition(1))
    flashlight.light:SetRotationf( CurveAngle( fw.main.camera.rotation.x, flashlight.light.rotation.x, 3.0/AppSpeed() ), CurveAngle( fw.main.camera.rotation.y, flashlight.light.rotation.y, 3.0/AppSpeed() ) )
    flashlight.light:Movef(-0.07,-0.04,0.02)
    
    fw:Render()
    DrawHUD(controller)
    Flip(0)
    end
    
    controller:Free()
    vwep:Free()
    
    ShowMouse()

  8. I think it's good to learn C++, because then you can do anything, and you can use it at the office too. Just don't make the mistake and learn old C++ (with pointers and new/delete operators), but learn the new C++ with references (instead of pointers) and STL (to replace pointers and new/delete needs) and Boost libraries.

    • Downvote 3
×
×
  • Create New...