draw to texture using memblocks by Phaelax21st May 2004 20:36
|
---|
Summary press the mouse button and move around the screen. The movements are written onto an image which has been textured to a plane. Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com screenwidth = 800 screenheight = 600 set display mode screenwidth,screenheight,32 load image "fog.bmp", 1, 1 make memblock from image 1, 1 width as dword height as dword depth as dword global width width = memblock dword(1,0) height = memblock dword(1,4) depth = memblock dword(1,8) size = get memblock size(1) make image from memblock 2, 1 sync on autocam off backdrop on position camera 0,0,0 make object plain 1, 100,100 position object 1, -50,0,400 texture object 1, 1 make image from memblock 2, 1 make object plain 2, 100,100 position object 2, 100,0,400 texture object 2,2 do if mouseclick()=1 fx = mousex()/(screenwidth/width) + 1 fy = mousey()/(screenheight/height) + 1 location = gridToSingle(fx, fy)* 4 + 12 write memblock dword 1, location, rgb(0,255,0) make image from memblock 1, 1 endif if mouseclick()=2 fx = mousex()/8 + 1 fy = mousey()/6 + 1 location = gridToSingle(fx, fy)* 4 + 12 write memblock dword 1, location, rgb(125,150,0) make image from memblock 1, 1 endif set cursor 0,0 print "width - ",width print "height - ",height print "depth - ",depth print "size - ",size print print screen fps() sync loop function gridToSingle(x as integer, y as integer) thing = (y-1)*width + x - 1 endfunction thing |