Diagonals not working and getting a stray frame

Blitz3D Forums/Blitz3D Beginners Area/Diagonals not working and getting a stray frame

fox95871(Posted 2009) [#1]
Hi, could someone please tell me how to get my diagonal controls to work? I think I get the gist of why they're not, something about them getting overridden by up down left and right, but I don't know how to fix it. Please help!



I'd also really like to know how to get rid of the stray frame you always see between directions.


Stevie G(Posted 2009) [#2]
What's with all the markers? You only need a single pivot ..

Global PIVOT = CreatePivot()

Function Controls()

	Dx = KeyDown(45) - KeyDown(44)
	Dz = KeyDown(200) - KeyDown(208)
	
	PositionEntity PIVOT, EntityX( character ) + Dx, EntityY( character ) , EntityZ( character ) + Dz
	PointEntity Character, PIVOT
	
End Function



Nate the Great(Posted 2009) [#3]
here I fixed it with some string addition and adding a variable facing2$




fox95871(Posted 2009) [#4]
Thanks for your suggestions! Can't wait to try them. Adding strings... hm, wouldn't have thought of that I don't think. Should be interesting to see. There's so many markers because I'm just starting out. Maybe one day I'll be able to understand the code you wrote, but this is still just the very beginning for me. My engine has so many parts, so the easier it is for me to understand each individual part, the happier I am coding, that's all!


Nate the Great(Posted 2009) [#5]
so you want to know what I did and how it works?

I have it check to see if you pressed left or right
if so then it sets the leftright string to left or right depending on what key you pressed
It then does the same with up and down and the updown string

After that it adds the updown string to the leftright string

I had to modify your select case slightly but it pretty much worked on the first try


fox95871(Posted 2009) [#6]
Perfect! Thanks Nate.

Anyone have any ideas on how to get rid of the stray frame now? It'd be pretty noticeable in a finished game. If you can't see what I mean, just keep turning the character around and you should see it, a non 45 or 90 degree type angle for one frame. I'm just a beginner, but it looks to me like Blitz is saying, "Okay, turn the character around? You got it!" but when you see Blitz actually goes through the process of turning it, you say, "No no, just make the character be turned around suddenly." and Blitz says, "Uh... can't really do that, yo."

Hopefully there's a purely code based fix for this, but if not I have thought of just making eight sets of meshes in Maya. It's no big, I'm already making seven for the antialiasing meshes. Oh wait, that's 56 then... ouch. Help!

Wait! It's because of the frame tween! I just turned it off now and the stray frame went away. Well, there's no way I'm getting rid of that, but if someone wants to try to mess around with it without breaking it, go for it. The frame tween, for anyone who doesn't know, makes it so no matter what computer you run your game on, it'll never run slow. It's these Holy lines of code:

;(in setup)
Const fps=30
period=1000/fps
time=MilliSecs()-period
elapsed%=0
ticks%=0
tween#=0
rt%=0

;(in the 3d loop)
While Not KeyHit(1)
Cls
Repeat
elapsed=MilliSecs()-time
Until elapsed
ticks=elapsed/period
tween#=Float(elapsed Mod period)/Float(period)
For rt=1 To ticks
time=time+period
If rt=ticks Then CaptureWorld
;(your code goes here)
UpdateWorld
Next
RenderWorld tween


I noticed that making fps 90 seems to fix it, but boy I don't think I want to do that for a finished game! Or is that okay?


fox95871(Posted 2009) [#7]
I'm heading into nights now, so I won't be able to use the internet for a while. Hopefully someone can answer this before then so I can work on this part of my engine while I'm on my night schedule. If nothing else, just what are the major upsides or downsides of making your game 90 fps? I guess the upside's clear in this case, it fixes the stray frame, but I don't want to end up with compatibility problems or any other weirdness.


fox95871(Posted 2009) [#8]
I added some moving controls and even running!



It'd still be good to know if using 90fps is going to blow up anyone's computer, but otherwise I'm really happy with this. Thanks so much for the help. I'm moving this to a new thread now to try to figure out it's other unrelated problems.

http://www.blitzbasic.com/Community/posts.php?topic=84307


Yasha(Posted 2009) [#9]
90 logical updates isn't going to hurt anything. Most machines can handle hundreds, although there's not much reason for this besides speed tests. The important FPS (from the perspective of possibly hurting computers) is the rendering rate. Since you're using Flip True this will always stay at the computer's local refresh rate, so it won't break it (at leat, not unless the user has already done something evil to their own machine). The one to watch out for is using Flip False without any kind of regulating code - trying to render hundreds of FPS may well kill the user's computer. But the CPU is designed to be used that way - being able to update the logic 90 times and only draw 60 (or whatever) is the entire point of render tweening; you're using it correctly.

On an entirely unrelated note, you don't need to Cls at the start of your main loop if the camera's going to draw over the entire screen anyway...


fox95871(Posted 2009) [#10]
What would have got me started using that? My notes say it's an old 2D command that's been replaced by RenderWorld and CameraClsMode in the 3D commands. Is that right?