Log In  

Hi everyone!

I'm hard at work on a 1-4 player cart, but I've run into a snag when it comes to moving a sprite around in a circle.

I more or less have the movement down (thanks to tonechild), but it looks like the wrong part of the sprite is tracing the circle I want:

(Please excuse the incomplete graphics and such.)

It appears that the upper-left corner of the sprite is tracing the circle here, when I'd really prefer something closer to the center of the sprite. Is there a way to make this happen? Or, if not, is there a workaround any of you might recommend?

Here are the relevant points of my (messy) code. You'll notice the star is able to "trace" the track because it uses the same variables I used to draw the circle.

 game_over=false   --determines that a solo player has lost
 player_win=false  --determines that a player won in multiplayer
 radius1=55  --determines outer circle size
 radius2=25  --determines inner circle size
 originx=63  --center of screen/track
 originy=63  --center of screen/track

 --star 1 data
--moves stars along track
 function move_stars()
  --moves star 1
   if star1.angle>360 then star1.angle=0
   elseif star1.angle<0 then star1.angle=360
 --draws track that stars follow
 function draw_track()

Thank you for reading, and for considering the problem! I promise I'll be a better forum participant in the near future, when I know a bit more about this whole Lua thing.

P#73965 2020-03-16 01:54

Just draw the sprite with an offset of -4 (half of sprite size)
eg. If you normally draw with spr(n, x, y), just change that to spr(n,x-4,y-4)

P#73967 2020-03-16 02:18
:: Ulexes

...I can't believe that didn't occur to me. Probably a sign I should go to bed soon!

An offset of -3 was perfect. Thank you for your help, finalpatch! I really appreciate it.

P#73969 2020-03-16 02:39

what is that game going to be

P#73971 2020-03-16 04:24
:: Ulexes

Dogerizer, I hope to make it a 1-4 player base defense game, where you press a button to activate a shield on either side of your core. The star will steadily speed up, and additional stars will be added the longer the game continues.

The one-player mode is intended to be a score attack until you run out of lives, and the two- to four-player modes should be survival modes.

I have a ways to go, but it's clicking along!

P#73973 2020-03-16 04:31

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-06-05 18:38 | 0.010s | 2097k | Q:17