I has a thought about what the best way to make ascii objects would be (like 2D objects, but made from ascii characters). It really would be silly to have to program in every ascii characters and it's positions and other data seperatelly, so I devised two functions:
num=asc_createObject(objlist$)
asc_drawObject(num,x,y)
So the first returns the object number, and the second will position that objects.
Objlist$, the parameter for the first function, it basically what the object will look like.
This is how you set it out:
char,x,y,size,r,g,b;
and that can be done over and over to make seperate objects in one line, aslong as you split it up using a semi-colon( ; ).
Here's the code, with a very.. sexy.. example
`ASCII Objects
sync on : sync rate 60
set display mode 1024,768,32 : hide mouse
`Ascii Data
type tasco
asclst as string
endtype
dim ascobj(0) as tasco
`Create ascii object
`[letter,x,y,size,r,g,b];
set text font "tahoma"
num=asc_createObject("(,-25,0,30,238,217,145;o,-15,6,10,255,0,0;Y,0,0,20,238,217,145;o,15,6,10,255,0,0;),25,0,30,238,217,145;")
`Main Loop
do
asc_drawObject(num,mousex(),mousey())
sync
cls
loop
`Functions - Ascii Objects
function asc_createObject(asclst$)
array insert at bottom ascobj() : num=array count(ascobj())
ascobj(num).asclst=asclst$
endfunction num
function asc_drawObject(obj,x,y)
lst$=ascobj(obj).asclst
for t=1 to getTokenCount(lst$,";")
curtok$=getToken(lst$,";",t)
cobj$=getToken(curtok$,",",1)
cx=val(getToken(curtok$,",",2))
cy=val(getToken(curtok$,",",3))
cs=val(getToken(curtok$,",",4))
cr=val(getToken(curtok$,",",5))
cg=val(getToken(curtok$,",",6))
cb=val(getToken(curtok$,",",7))
set text size cs : ink rgb(cr,cg,cb),0
center text x+cx,y+cy-(text height(cobj$)/2),cobj$
next t
endfunction
`Functions - String
function getToken(st$,t$,num)
if right$(st$,len(t$))<>t$ then st$=st$+t$
if left$(st$,len(t$))<>t$ then st$=t$+st$
for s=1 to len(st$)
cur$=mid(st$,s,len(t$))
if cur$=t$ then inc count
if count=num then pos=s+1 : exit
next s
for s=pos to len(st$)
tok$=tok$+mid$(st$,s)
if mid(st$,s,len(t$))=t$ then exit
next s
tok$=left$(tok$,len(tok$)-1)
tok$=right$(tok$,len(tok$)-(len(t$)-1))
endfunction tok$
function getTokenCount(st$,t$)
if right$(st$,len(t$))<>t$ then st$=st$+t$
if left$(st$,len(t$))<>t$ then st$=t$+st$
for s=1 to len(st$)
cur$=mid(st$,s,len(t$))
if cur$=t$ then inc count
next s
dec count
endfunction count
function mid(st$,p,ln)
l=ln-1
for s=p to p+l
new$=new$+mid$(st$,s)
next s
endfunction new$
[edit]
Here's another cool object:
num=asc_createObject(" )),0,0,12,255,255,255; ( ¬¬),0,12,12,255,255,255;/_(')'),0,24,12,255,255,255;")