Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / line rotation, is it possible?

Author
Message
Mucky Muck Ninja
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location: im not entirely sure
Posted: 10th Jan 2004 07:06
im making a simple 2d game that uses no media so Im using circles and lines and boxes. My problem is, i want a line that is sticking out of a circle, to rotate around the center of the circle, like a turret. Ive tried various things and nothing has worked. Any ideas?

Am I an Idiot...or is everyone else just really smart?
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 10th Jan 2004 08:14
Will this help?



Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Axelman
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location: Parallel Universe
Posted: 10th Jan 2004 11:09
no offense easily confused, but i din't think they have a command called rotateline.i would use a sprite ,but you said you aren't using any media.
try this.(it probably won't work)


i'm pretty sure this won't work, because everything i do in darkbasic screws up(sob) but at least give it a try

nothing right in my left brain:nothing left in my right brain
ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 10th Jan 2004 11:13
easily confused's code works for me axel... don't you know about functions? he made that rotateline function and it is declared at the bottom of his program. it works


GO TO THE ETERNAL DESTINY FORUMS!!! http://forums.eternaldestinyonline.com
Do it now!!!
Macabre
21
Years of Service
User Offline
Joined: 15th Jan 2004
Location:
Posted: 16th Jan 2004 04:08
Well this code can do the trick ...
Afcource u can modify it to move anything around a circle or elipse.
I hope this helps ..

by the way , if ya wanna speed it up more , then you can mak an array to hold the calculation it self (sin(i)/rd and cos ...)
That way its faster, but still scaleble and moveble.
And u can 'mirror' the circle over the x and y axis to, so that way u only have to draw 1/4 of an circle or 1/2 if ya wanna do an elipse.

rem rotating line
sync on:rem NEEDED else it will flicker !
sync rate 30
pi = 4*atan(1): rem to calculate PI more accurate ...
rd = pi/180:rem little conversion for sin/cos is needed.

Xorg = 320:Yorg=240:rem This is the center of your circle(now the screen)
xRd = 100:rem The radius of the circle (x-axis)
yRd = 100:rem radius for the y-axis (so oval is possible to !)
stp = 1:rem The stepping used in the for next loop

do

for i = 0 to 360 step stp:rem 0 to 360 is an full circle

x=Xorg+xRd*(sin(i)/rd):rem calculate the x position
y=Yorg+yRd*(cos(i)/rd):rem calculate the y position
ink rgb(255,255,255),rgb(0,0,0):rem color white
line Xorg,Yorg,x,y:rem draw the line
sync:rem wait for a vertical retrace
ink rgb(0,0,0),rgb(0,0,0):rem color black
line Xorg,Yorg,x,y:rem delete the line
next i
loop
Macabre
21
Years of Service
User Offline
Joined: 15th Jan 2004
Location:
Posted: 16th Jan 2004 04:12
by the way , youre not an idiot, you simple cant now everything -- that will make youre head explode --

there may be some beter ways/or special commands in DB, i just have it for 1 day ...but it realy works...(so the code i gave you is a bit ancient used it in som msx-basic an gw-basic proggie's)
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Jan 2004 04:39
This function will draw a line of a specified length extending from the specified origin, rotated by the specified angle.




If you want end of the line to rotate around the outside of the circle, instead of being stationary in the center of the circle, let me know and I'll write a function for that.

"eureka" - Archimedes

Login to post a reply

Server time is: 2025-05-22 07:06:56
Your offset time is: 2025-05-22 07:06:56