Jump to content

Precise top down player control

prolemur

So far I am working on a little raycasting game and it will be graphically similar to the likes of doom. So far I am working on the top down 2d view because that will have all the information I need to remake it into '3d' and it would be cool to be able to choose which mode to play in. I want to get more precise tracking right now though, but I don't know how to as it won't let me use decimals as a rotation speed and I want the character to follow directly on the line of its direction it is facing using the slope of the line to increment each update. Also there is a glitch when you look into a corner it will skip more than the other angles do so it would make it hard to play, I think this is another problem with not being able to use decimals as from some code it was maxy div 90 which is for example 8.888... but the computer is only taking the int: 8.

var x : int := midxvar y : int := midyvar circle : int := 360var d : int := 0var dir : int    if dir >= 0 and dir < 90 then        Draw.Line (x, y, maxx, dir * (maxy div 90), 1)    elsif dir >= 90 and dir < 180 then        Draw.Line (x, y, maxx - (dir - 90) * (maxx div 90), maxy, 1)    elsif dir >= 180 and dir < 270 then        Draw.Line (x, y, 0, maxy - (dir - 180) * (maxy div 90), 1)    elsif dir >= 270 and dir < 360 then        Draw.Line (x, y, (dir - 270) * (maxx div 90), 0, 1)    end if

Also this is turing and if you want to download the compiler/ide here's the link

 

Edit* I will be making this in c++ using a 2d graphics library after I get the functionality done with a language and lib that I fully understand. But than again maybe this would work in c++ and this language is just bad... :P

Link to comment
Share on other sites

Link to post
Share on other sites

Here's a quick fix for your jumping problem. You just need to do the angle calc as a real then use floor() to convert to int for plotting the line.

    var angle : real := 0    if dir >= 0 and dir < 90 then        angle := dir * (maxy / 90)        Draw.Line (x, y, maxx, floor(angle), 1)    elsif dir >= 90 and dir < 180 then        angle := maxx - (dir - 90) * (maxx / 90)        Draw.Line (x, y, floor(angle), maxy, 1)    elsif dir >= 180 and dir < 270 then        angle := maxy - (dir - 180) * (maxy / 90)        Draw.Line (x, y, 0, floor(angle), 1)    elsif dir >= 270 and dir < 360 then        angle := (dir - 270) * (maxx / 90)        Draw.Line (x, y, floor(angle), 0, 1)    end if

main(i){for(;i<101;i++)printf("Fizz\n\0Fizzz\bBuzz\n\0%d\n"+(!(i%5)^!!(i%3)*3)*6,i);}

Link to comment
Share on other sites

Link to post
Share on other sites

Here's a quick fix for your jumping problem. You just need to do the angle calc as a real then use floor() to convert to int for plotting the line

thanks that function is really nice :)

except now the aim of the character is off for now, it is better I need to just change some of it to fix the change in the physics procedure.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×