The Best MouseLook Code.

Blitz3D Forums/Blitz3D Programming/The Best MouseLook Code.

Chroma(Posted 2007) [#1]
Hi...I'd like to start a contest for the best mouselook code. Sounds simple but you'd be surprised how flaky mousecode can be, running across many different cpu speeds and framerates.

You should shoot for AAA quality mouselook that is smooth across all framerates (30-1000 frames per second). You can just put the code here in a codebox.

Everyone can vote. Rate it on a scale from 1 to 10 with 1 totally sucking and 10 being the perfect mouselook code.

The winner will receive the book Isometric Game Programming with DirectX 7.0 by Pazera and LaMothe.


bytecode77(Posted 2007) [#2]
it's a complete freelook function :)


Fuller(Posted 2007) [#3]
Funny idea for a competition... Let me guess you need good mouselook code for your upcoming game, Wiggle and FreeLook around!

ah.. I'm just kidding... I might enter.


Mattizzle(Posted 2007) [#4]
Here yah go:

;****************************************************
; Camera Controls Extracted from "Advanced Scene Loading in Blitz3D"
; By: LeadWerks www.leadwerks.com
; Maker of 3DWorldStudio
;****************************************************

Graphics3D 800,600,0,2
SetBuffer BackBuffer()
AppTitle "Blitz3D"
HidePointer()

Global cam
cam=CreateCamera()
CameraRange cam,1,10000
CameraZoom cam,1.4

Dim cube(200)
For n=1 To 200
cube(n) = CreateCube()
ScaleEntity cube(n), Rand(1,50),Rand(1,50),Rand(1,50)
PositionEntity cube(n), Rand(-1000,1000),Rand(-1000,1000),Rand(-1000,1000)
Next

mousespeed#=0.5
cameraspeed#=10
camerasmoothness#=3
	
While Not KeyHit(1)
	
	;Camera controls
	mx#=CurveValue(MouseXSpeed()*mousespeed,mx,camerasmoothness)
	my#=CurveValue(MouseYSpeed()*mousespeed,my,camerasmoothness)
	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
	pitch#=EntityPitch(cam)
	yaw#=EntityYaw(cam)
	pitch=pitch+my
	yaw=yaw-mx
	If pitch>89 pitch=89
	If pitch<-89 pitch=-89
	RotateEntity cam,0,yaw,0
	TurnEntity cam,pitch,0,0
	
	cx#=(KeyDown(32)-KeyDown(30))*cameraspeed
	cz#=(KeyDown(17)-KeyDown(31))*cameraspeed
	MoveEntity cam,cx,0,cz

	RenderWorld()
	Flip
Wend
	
Function CurveValue#(newvalue#,oldvalue#,increments )
If increments>1 oldvalue#=oldvalue#-(oldvalue#-newvalue#)/increments
If increments<=1 oldvalue=newvalue
Return oldvalue#
End Function



jfk EO-11110(Posted 2007) [#5]
Mattizzle, I don't get it, your entry is written by Halo? then let' shope he will like "Isometric Game Programming with DirectX 7.0" :o)

As a specie from planet earth I can tell you, there's something wrong with both entries so far, telling me the code was never used in a real game. (edit: at least not in a fps game)

They don't use a player pivot. You need a player pivot. Otherwise you'll be walking slower, the higher you look up to the sky etc.

Therefor, you will alter the pitch of the camera to look up and down, but the yaw of the parental player pivot to turn left and right (as well as to move the player, for that matter).

Cheers


Chroma(Posted 2007) [#6]
Funny idea for a competition... Let me guess you need good mouselook code for your upcoming game, Wiggle and FreeLook around!


Wrong. Just trying to have some fun. I have my own mouselook code that works great. Nice attempt to troll though.


Naughty Alien(Posted 2007) [#7]
I agree with Chroma...knowing this community, I am sure that with their generosity he dont have to create forum like this to get some nice and decent mouselook code...its enough just to ask..


Chroma(Posted 2007) [#8]
Ok here's my mousecode I use. Hit the "=" key change from Flip True to Flip False.

EDIT: Added in a sniper scope. Press RMB to toggle between 1x and 3x power.




Mattizzle(Posted 2007) [#9]
Jfk, this is just test mouse look code... not code for a real instance of a game. I have added much to this for my own game and turned it into a third person camera.


Chroma(Posted 2007) [#10]
Well...I guess the contest failed. Hmm...maybe it should be something a bit more challenging with a better reward. Any ideas?


bytecode77(Posted 2007) [#11]
if i wanted to be wickedly, i would suggest a contest about shadows :D :D :D


little_iris(Posted 2007) [#12]
Hi!
how do I reverse the pitch in Devils Childīs mouseLook code?
thanks


bytecode77(Posted 2007) [#13]
FreeLookRotYS# = ((-MouseYSpeed() - FreeLookRotYS#) * .2 + FreeLookRotYS#) * .9 ;===================> -MouseySpeed()