Soemthing to get you started
// Project: imagedecals
// Created: 2018-12-24
// show all errors
SetErrorMode(2)
#constant screenwidth=1024
#constant screenheight=768
#constant fullscreen=0
#constant screenrate=0
// set window properties
SetWindowTitle( "imagedecals" )
SetWindowSize( screenwidth, screenheight, fullscreen )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( screenwidth, screenheight ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( screenrate, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
// create an image this could be any image that you want to loadimage with
swap()
DrawBox(0,0,128,128,MakeColor(0,255,255),MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),1)
Render()
img = getimage(0,0,128,128)
memoryimage = CreateMemblockFromImage(img)
// end
obj = CreateObjectPlane(10,10)
SetObjectRotation(obj,0,0,0)
SetObjectImage(obj,img,0)
do
if GetRawMouseLeftState()
newimage = drawdecalonimage(memoryimage,128,128)
SetObjectImage(obj,newimage,0)
endif
Print( ScreenFPS() )
Sync()
loop
function drawdecalonimage(memblockid, sizex,sizey)
imgwidth = GetMemblockInt(memblockid, 0)
offset = 12 + (((random(0,sizey-1)) * imgwidth) + (random(0,sizex-1))) * 4
if offset>0
SetMemblockByte(memblockid,offset,MakeColor(0,0,0))
SetMemblockByte(memblockid,offset+1,MakeColor(0,0,0))
SetMemblockByte(memblockid,offset+2,MakeColor(0,0,0))
endif
img = CreateImageFromMemblock(memblockid)
endfunction img
Press left mouse button for a bullet shot