Oxygen Basic
Programming => Example Code => Topic started by: Peter on December 20, 2013, 04:11:50 PM
-
:D :D :D
-
Peter,
I think our Ellipse functions are different. I'm getting a segmentation fault passing your parameters.
I attached a screen shot of your O2 example that you forgot.
void Draw_Ellipse(SDL_Surface *super,
Sint16 x0, Sint16 y0,
Uint16 Xradius, Uint16 Yradius,
Uint32 color);
Draw a ellipse with center in x0,y0. Xradius is the major axis and Yradius is
the minor axis.
' ScriptBasic Ellipse
DECLARE SUB Window ALIAS "SB_Window" LIB "sdl"
DECLARE SUB WaitKey ALIAS "SB_WaitKey" LIB "sdl"
DECLARE SUB UpdateRect ALIAS "SB_UpdateRect" LIB "sdl"
DECLARE SUB RGB ALIAS "SB_RGB" LIB "sdl"
DECLARE SUB CLS ALIAS "SB_CLS" LIB "sdl"
DECLARE SUB Draw_Ellipse ALIAS "SB_Draw_Ellipse" LIB "sdl"
Window 800, 600, "ScriptBasic Ellipse"
width = 400
height= 300
CLS(RGB(255, 255, 255))
black = RGB(0, 0, 0)
FOR i = 0 to 260 step 10
IF i % 20 = 0 THEN
Draw_Ellipse width, height, -i, -i, black
Draw_Ellipse width, height, i, i, black
ELSE
Draw_Ellipse width + i, height, -i, -i, black
Draw_Ellipse width -i, height, i, i, black
END IF
NEXT
UpdateRect
WaitKey
.
-
I went with Mike's (FBSL) direction and used Draw_Circle() instead. I would still like to get the Draw_Ellipse() function to work if possible.
(http://files.allbasic.info/ScriptBasic/sbcircle.png)
' ScriptBasic Circle
DECLARE SUB Window ALIAS "SB_Window" LIB "sdl"
DECLARE SUB WaitKey ALIAS "SB_WaitKey" LIB "sdl"
DECLARE SUB UpdateRect ALIAS "SB_UpdateRect" LIB "sdl"
DECLARE SUB RGB ALIAS "SB_RGB" LIB "sdl"
DECLARE SUB CLS ALIAS "SB_CLS" LIB "sdl"
DECLARE SUB Draw_Circle ALIAS "SB_Draw_Circle" LIB "sdl"
Window 800, 600, "ScriptBasic Circle"
w = 400
h = 300
CLS(RGB(255, 255, 255))
black = RGB(0, 0, 0)
FOR i = 0 TO 130 STEP 10
Draw_Circle w - i, h + i, i, black
Draw_Circle w + i, h - i, i, black
Draw_Circle w + i, h + i, i, black
Draw_Circle w - i, h - i, i, black
NEXT
UpdateRect
WaitKey