ID:133452
 
I've been worknig on an Asteroids like game. I draw everything to the screen rather than move objs around. I've included a link so you can view my project. I use datums to determine where to draw the shapes on the screen. I've found out that if I let it set for awhile I get the following error:

runtime error: Maximum number of rsc entries exceeded.
proc name: RscFile (/icon/proc/RscFile)
source file: ,0
usr: null
src: /icon (/icon)
call stack:
/icon (/icon): RscFile()
DrawScreen()
RefreshScreen()
RefreshScreen()

It's named RayCasting because I was working on doing raycasting till I stumbled upon how to rotate shapes. I ended up working on a game like asteroids.

http://www.byond.com/members/Zaltron/files/RayCasting.zip

I'd like it so I don't have to store icon files to the cache so I can keep drawing to the screen without worrying about the garbage_collection collecting icons that aren't used anymore.

An example of how it could be used:

icon
store_in_cache = 0

//or

icon/temp
store_in_cache = 0

mob/verb/test()
var/icon/temp/i = icon('blah.dmi',"blah")


Once i wasn't referenced anymore it'd never be heard from again!

Here's some code so you can see how I'm drawing to the screen:


world
view = "6x6"
name = "Asteroids"
//tick_lag = 0.8
New()
..()
world.maxx = 6
world.maxy = 6
world.maxz = 1
for(var/x = 1 to size)for(var/y = 1 to size)
var/icon/i = icon('Sprites.dmi',"back")
Buffer[x][y] = i

...[code]
Edited[px][py] = 1
var/icon/i = Buffer[px][py]
if(c > 0)
i.DrawBox(rgb(255,255,255),x % 32 + 1,y % 32 + 1)
else
i.DrawBox(rgb(0,50,100),x % 32 + 1,y % 32 + 1)


proc/DrawScreen()
for(var/x = 1 to size)for(var/y = 1 to size)
var/turf/t = locate(x,y,1)
t.icon = Buffer[x][y]
for(var/x = 1 to size)for(var/y = 1 to size)if(Edited[x][y])
Edited[x][y] = 0
var/icon/i = icon('Sprites.dmi',"back")
Buffer[x][y] = i


proc/RefreshScreen()
DrawScreen()
for(var/Shape/s in Shapes)s.MoveShape()
spawn(1)RefreshScreen()


As for the creating a blank icon function. I'd like to be able to use DrawBox on an icon that's created through the following code: var/icon/i = new. Right now I have to write the following: var/icon/i = icon('Sprites.dmi',"back"). otherwise DreamSeeker won't load. The reason I want this is so I don't need to provide a .rsc file.
Unfortunately the part about not caching the icon isn't as feasible as it sounds. All icon drawing is based on the idea of having a cache to draw the icons from, and the cache isn't garbage-collected. This is one of the long-term changes I'd like to make at some point.

Lummox JR