My Daily Gist | Ferdinand Silva


Titik Programming Language / Interpreter SDL2 Sample Code

 
^
SDL2 Sample Code
================
^
#init sdl
if(!(s_i(S_E)))
abt('Unable to initialize SDL...')
fi
#create window
win = s_cw("Test", S_WP_U, S_WP_U, 800, 600, S_W_S)
if(win == Nil)
abt('Unable to create window...')
fi
#get window surface
surface = s_gsw(win)
if(surface == Nil)
abt('Unable to get window surface...')
fi
#fill window with black color
s_frsw(surface, "", 0)
#create rectangle, 200x200, x=0, y=0
rct = s_cr(0, 0, 200, 200)
if(rct == Nil)
abt("Unable to create rectangle...")
fi
#fill the rectangle with red color
s_frsw(surface, rct, 4294901760)
#update window surface
s_usw(win)
#main infinite loop
wl(T)
#poll event
event = s_pe()
#get event type
event_type = s_gte(event)
#if the event is QUIT then break the main loop
if(event_type == S_E_Q)
brk
fi
#clear the event
s_ce(event)
lw
#destroy window on exit
s_dw(win)
#quit sdl app
s_q()
view raw test.ttk hosted with ❤ by GitHub