Skip to content

Instantly share code, notes, and snippets.

@six519
Created November 10, 2022 02:53
Show Gist options
  • Save six519/56a315510bc53e5379a032a5b5fc7ebb to your computer and use it in GitHub Desktop.
Save six519/56a315510bc53e5379a032a5b5fc7ebb to your computer and use it in GitHub Desktop.
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment