Layers for grapics?

BlitzMax Forums/BlitzMax Programming/Layers for grapics?

This works
Graphics 800,600

Local Cave:TImage = LoadImage("cave.png") 'load the cave graphic
Local Player:TImage = LoadImage("player.png") 'load the player graphic
MidHandleImage Player
Local PlayerX:Int = 400 'Player x position
Local PlayerY:Int = 300 'Player y position
SetClsColor 0,0,0 'make sure cls color is black (Defaults to that anyway)
'use other values for cls color to illuminate the cave at different levels


While Not KeyHit(KEY_ESCAPE)
	Cls 'clear the backbuffer
	
	SetBlend SOLIDBLEND 'draw solid
	DrawOval PlayerX - 64, PlayerY - 64,128,128 'draw a circle around the player
	
	SetBlend SHADEBLEND 'draw multiply
	DrawImage Cave,0,0
	
	SetBlend ALPHABLEND 'draw with alpha
	DrawImage Player,PlayerX,PlayerY

	Flip
	
	If KeyDown(KEY_LEFT) Then PlayerX :- 1
	If KeyDown(KEY_RIGHT) Then PlayerX :+ 1
	If KeyDown(KEY_UP) Then PlayerY :- 1
	If KeyDown(KEY_DOWN) Then PlayerY :+ 1
Wend


using shade blend will multiply the colors of the image with what is already on the backbuffer. So you draw a white circle wherever you want the cave to be lit up using SolidBlend, then draw the cave on top using ShadeBlend. You could also use AlphaBlend on the oval and use a TImage with fading alpha to simulate light dropoff.