Challenge:
Winner?:
No
Code Snippet:
`constants #constant SCREEN_WIDTH = 1024 #constant SCREEN_HEIGHT = 768 #constant SCREEN_DEPTH = 32 #constant CHAR_WIDTH = 8 #constant CHAR_HEIGHT = 13 #constant CHAR_SIZE = 10 #constant CHAR_FONT = "lucida console" `colors #constant BLACK = rgb(0,0,0) #constant WHITE = rgb(255,255,255) #constant RUBY = rgb(255,0,0) `\ #constant EMERALD = rgb(0,255,0) ` } can't use red, green, and blue as constants #constant SAPPHIRE = rgb(0,0,255) `/ #constant PURPLE = rgb(128,0,128) `initialization sync on : sync rate 0 set display mode SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_DEPTH set text size CHAR_SIZE set text font CHAR_FONT `pre-loop code initCharSystem() `main loop do fillChars(rnd(255),randColor()) placeString("Hello World!",rnd(xChars),rnd(yChars),randColor()) placeString("FPS: "+str$(screen fps()),0,0,WHITE) renderChars() : sync loop `------------------------------------------ `################## types ################# `------------------------------------------ `charcter array type type charType value as dword color as integer endtype `------------------------------------------ `############# main functions ############# `------------------------------------------ `initializes the character system function initCharSystem() global xChars as integer global yChars as integer xChars=SCREEN_WIDTH/CHAR_WIDTH yChars=SCREEN_HEIGHT/CHAR_HEIGHT dim char(xChars,yChars) as charType endfunction `renders all characters to screen function renderChars() cls for x=0 to xChars for y=0 to yChars ink getCharColor(x,y),BLACK if (x*CHAR_WIDTH<SCREEN_WIDTH) and (y*CHAR_HEIGHT<SCREEN_HEIGHT) text x*CHAR_WIDTH,y*CHAR_HEIGHT,chr$(getCharValue(x,y)) endif next y next x endfunction `places a string in the character grid function placeString(str as string,x as integer,y as integer,color as integer) for p=1 to len(str) if (x+(p-1)<=xChars) then setChar(x+(p-1),y,asc(mid$(str,p)),color) next p endfunction `fills screen with a single charcter of a certain color function fillChars(value as dword,color as integer) for x=0 to xChars for y=0 to yChars setChar(x,y,value,color) next y next x endfunction `fills screen with a single character function fillCharValues(value as dword) for x=0 to xChars for y=0 to yChars setCharValue(x,y,value) next y next x endfunction `fills screen with a certain color function fillCharColors(color as integer) for x=0 to xChars for y=0 to yChars setCharColor(x,y,color) next y next x endfunction `------------------------------------------ `########## data member functions ######### `------------------------------------------ `set's both attributes of a character function setChar(x as integer,y as integer,value as dword,color as integer) setCharValue(x,y,value) setCharColor(x,y,color) endfunction `sets a character's ascii value function setCharValue(x as integer,y as integer,value as dword) char(x,y).value=value endfunction `sets a character's color function setCharColor(x as integer,y as integer,color as integer) char(x,y).color=color endfunction `gets a character's color function getCharColor(x as integer,y as integer) color as integer color=char(x,y).color endfunction color `gets a character's value function getCharValue(x as integer,y as integer) value as dword value=char(x,y).value endfunction value `------------------------------------------ `######### miscellaneous functions ######## `------------------------------------------ `returns a random color function randColor() color as integer color=rgb(rnd(255),rnd(255),rnd(255)) endfunction color