if(!(s_it())) # init ttf | |
abt('Unable to init ttf...') | |
fi | |
if(!(s_i(S_E))) # init sdl | |
abt('Unable to initialize SDL...') | |
fi | |
win = s_cw("Test", S_WP_U, S_WP_U, 800, 600, S_W_S) #create window | |
if(win == Nil) | |
abt('Unable to create window...') | |
fi | |
fnt = s_oft("test.ttf", 32) #open font | |
if(fnt == Nil) | |
abt('Unable to initialize font...') | |
fi | |
text = s_rft(fnt, "Hello, World!", 255, 191, 0, 255) #render font (amber color) | |
if(text == Nil) | |
abt('Unable to create text...') | |
fi | |
surface = s_gsw(win) #get window surface | |
if(surface == Nil) | |
abt('Unable to get window surface...') | |
fi | |
dd = s_gdsw(text) #get surface dimension | |
xx = 400 - (dd['width'] / 2) | |
yy = 300 - (dd['height'] / 2) | |
rct = s_cr(xx, yy, 0, 0) #create rectangle | |
s_bsw(text, "", surface, rct) #text blit | |
s_usw(win) | |
wl(T) | |
event = s_pe() | |
event_type = s_gte(event) | |
if(event_type == S_E_Q) | |
brk | |
fi | |
s_d(16) | |
s_ce(event) | |
lw | |
s_fsw(text) #free surface | |
s_cft(fnt) #close font | |
s_dw(win) #destroy window | |
s_qt() #quit ttf | |
s_q() #quit sdl |
^ | |
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() |
irc_port = 6667 | |
socket = "" | |
irc_server = r("Please Enter IRC Server Address: ") | |
irc_nick = r("Please Enter IRC Nick: ") | |
irc_channel = r("Please Enter IRC Channel: ") | |
socket = netc("tcp", irc_server + ":" + tos(irc_port)) | |
socket_msg = "" | |
wl (T) | |
socket_msg = netr(socket, 1024) | |
if (str_ind(socket_msg, "ERROR :Closing link:") > -1) | |
brk | |
ef (str_ind(socket_msg, "Looking up your ident") > -1) | |
netw(socket, "NICK " + irc_nick + "\n") | |
netw(socket, "USER " + irc_nick + ' "' + irc_nick + '.com" "' + irc_server + '" : ' + irc_nick + " robot\n") | |
ef (str_ind(socket_msg, "PING ") > -1) | |
netw(socket, str_rpl(socket_msg, "PING", "PONG") + "\n") | |
ef (str_ind(socket_msg, "End of message of the day") > -1) | |
netw(socket, "JOIN #" + irc_channel + "\n") | |
ef (str_ind(socket_msg, "PRIVMSG #" + irc_channel) > -1) | |
netw(socket, "PRIVMSG #" + irc_channel + " :The message is: " + str_spl(socket_msg, "PRIVMSG #" + irc_channel + " :")[1] + "\n") | |
fi | |
p(socket_msg) | |
lw |