Jump to content

Recommended Posts

Hi, I'm new here - the name's Cambertian. You might know me from a few other gaming forums.

 

Just like I'm new to these forums, I'm new to 7800basic. I'm in the process of making a golf game similar to Mario Golf on the Game Boy Color, but without all of the RPG/story mode gimmicks, different golf clubs, or a lot of the extra fluff. So far I've gotten it to display one of the maps and a tiny bit of the HUD. There's no interactivity just yet.

 

Basically, I was wondering how I could get a "rotating" cursor to aim your shots with. I'm assuming there's no sine or cosine functions to work with, and I'm assuming that's what I need, so I'm wondering about a good implementation method for them.

 

I was thinking of using my Calculus experience and using a Taylor series approximation to get part of each function, then "looping" around once they get past the point of inaccuracy. I'm worried about using too much memory while making the calculations, though, so I'm thinking there must be a better way...

 

Has anyone attempted this before? Would you be willing to point me in the right direction? It doesn't have to be code-snippets - just drop a name or algorithm and I'll do the research.

 

Thanks!

 

- Cambert

Link to comment
https://forums.atariage.com/topic/230098-rotation-question/
Share on other sites

Welcome Cambert!

 

With the 6502 you're almost always better off building a lookup table, rather than trying to run complex math on the CPU. The lookup table will always be quicker and use less ram, and depending on the math and requirements it might use less rom too.

 

I wrote a spacewar clone for the 2600 a while back that had a fair bit of complex math, boiled down into tables. Each player has acceleration variables for each axis, as well as position variables. The player has a rotation variable, which is used as an index to the "thrust table". When the player fire button is down, the thrust values are added to the acceleration variables. Every frame the acceleration variables are added to the corresponding position variables. Another lookup table affected your acceleration based on the screen position relative to the sun. In the end, it was all accurate enough for the ships to be able to enter quite stable orbits around the sun, if one thrusted carefully.

 

None of that is directly applicable to your game, but hopefully it may spark some ideas on how you can break down your own higher math into lookup tables. A rotating cursor is easy enough with a straight sine table, scaled as you need. Things may get a bit more complicated when you work on the ball velocity.

  • Like 2
Link to comment
https://forums.atariage.com/topic/230098-rotation-question/#findComment-3078931
Share on other sites

Yes, look up tables are your friend; although occasionally an approximation will work well enough while being both more time & space efficient. (e.g. max(x,y)+min(x,y)/2 as an approximation for sqrt(x*x+y*y) ) For something like a golf game you could do a 256 entry LUT for a quarter of a circle so your player wouldn't be restricted to a small set of angles.

 

I did a version of SpaceWar! for the 7800. Calculating the LUTs for gravity was a royal pain, but the end result was worth it.

  • Like 1
Link to comment
https://forums.atariage.com/topic/230098-rotation-question/#findComment-3079541
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...