C++ Student, need help with very simple concept

Joined
Mar 13, 2023
Messages
2
Reaction score
0
Hi!

I've been asked by my group in Video Games Programming to make a sprite go from one side of the screen to the other on a curve that reaches towards the top of the screen. It is a sun, and I was thinking it should be done similarly to Terraria's sun, but I've missed a few sessions due to illness and am not confident I could figure out a way to do it without telling it to adjust its trajectory every so often to create a curve.

I know this is a simple, but I'm getting back into my course after being hospitalized and don't want to disappoint them. I couldn't find much online for something this kind of specific, and I feel like telling it to adjust its velocity/ y acceleration would create a curve that's too harsh, and creating a timer using a variable adjusting them might be overengineering it.

Thank you for anyone willing to help.
 
Joined
Sep 21, 2022
Messages
125
Reaction score
16
The easiest curve is a circle.

Start with moving a sprite in a circle.

Three functions would be useful.

angle as a function of time (this is the hard one, depends on the way time is handled in the game, and which direction the sun is moving)

x as a function of angle (see any math book)

y as a function of angle (see any math book)

Get that animation working, then change the centre and radius of the circle to put the path of the sun (a small part of the upper arc) where you want it.

Just a suggestion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top