Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help moving a sprite in a ellipse
#2
Here is the simplest example I could come up with. This code creates 360 points around a circle. By varying XSIZE and YSIZE you can squash (YSIZE) or elongate (XSIZE) the ellipse.

Replace the CIRCLE command with your sprite's _PUTIMAGE statement.

Code: (Select All)


CONST RADIUS = 200

CONST XSIZE = 1
CONST YSIZE = .5


DIM x(359) AS SINGLE
DIM y(359) AS SINGLE

FOR i = 0 TO 359
    x(i) = SIN(_D2R(i)) * RADIUS * XSIZE
    y(i) = -COS(_D2R(i)) * RADIUS * YSIZE
NEXT i

SCREEN _NEWIMAGE(640, 480, 32)
CLS

i = 0
DO

    _LIMIT 60
    CLS
    CIRCLE (319 + x(i), 239 + y(i)), 20

    i = i + 1
    IF i = 360 THEN i = 0
    _DISPLAY
LOOP UNTIL _KEYDOWN(27)
There are two ways to write error-free programs; only the third one works.
QB64 Tutorial
Reply


Messages In This Thread
help moving a sprite in a ellipse - by Cobalt - 07-06-2023, 12:21 AM
RE: help moving a sprite in a ellipse - by TerryRitchie - 07-06-2023, 01:04 AM
RE: help moving a sprite in a ellipse - by bplus - 07-06-2023, 01:48 AM
RE: help moving a sprite in a ellipse - by bplus - 07-06-2023, 12:13 PM
RE: help moving a sprite in a ellipse - by bplus - 07-06-2023, 01:02 PM
RE: help moving a sprite in a ellipse - by Cobalt - 07-06-2023, 05:33 PM



Users browsing this thread: 1 Guest(s)