#Nature of code - Fire Simulation #*********************************************************************** # The Nature of Code chapter has a piece on image textures and blending. It can do that because it has functions like tint (which tints an image using a color) and blendmodes like additive blending. BASIC-256 can load images but can't change the tint and although there are no specific blend modes, using alpha allows you to do additive blending) # So, while we still want a smoke/fire simulation, we'll take it step by step and start by creating our own fuzzy circle/smoke particle from scratch # gosub ScreenSetup gosub FuzzyDeclaration while true gosub Show end while ScreenSetup: Fastgraphics # write to video buffer. width=200 height=200 # good practice to put every constant in a variable. graphsize width,height color black rect(0, 0, width, height) refresh return FuzzyDeclaration: # originpoint of the fuzzy circle center_x= width/2 center_y = height/2 # color of the fuzzy circle (white) col = 255 # Radius of the Fuzzy circle radius = 30 # Decrease in the circle diameter. Also influences alpha stepsize = 2 #alpha factor alpha = 30/2 # how far it moves from the center to the left and to theright move_x=50 inc = 2 return Show: # Now we show the fuzzy circle by drawing ever smaller circles with the same small alpha and then move it from left to right and back via the move_x parameter # oscillate between 30 left and right of the centre for loc_x = center_x - move_x to center_x + move_x step inc # we'll make circles decreasing with 'stepsize' and overlaying each circle with the next smaller one. This causes additive blending of the circles for x= radius to 1 step -stepsize color rgb(col,col,col,alpha) circle (loc_x,center_y,x) next x refresh pause 0.02 color black rect(0, 0, width, height) next loc_x move_x=-move_x inc = -inc return