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.

 --variables
 scene="logo"
 last=time()
 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
 flashcol=11

 --star 1 data
 star1={}
  star1.exist=false
  star1.angle=13
  star1.x=originx+radius1*cos(star1.angle/360)
  star1.y=originy+radius1*sin(star1.angle/360)
  star1.speed=3
  star1.sprite=56
--moves stars along track
 function move_stars()
  --moves star 1
   star1.angle+=star1.speed
   star1.x=originx+radius1*cos(star1.angle/360)
   star1.y=originy+radius1*sin(star1.angle/360)
   if star1.angle>360 then star1.angle=0
   elseif star1.angle<0 then star1.angle=360
   end
 end
 --draws track that stars follow
 function draw_track()
  circ(originx,originy,radius1,2)
  circ(originx,originy,radius2,2)
 end 

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.



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)


...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.


what is that game going to be


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!



[Please log in to post a comment]