Discord
Login
Community
DARK THEME

execution order

how do i order execution im making a falling sand game and diagonal falling runs at the same time as vertical dulicating the particle

Show the project code.

Tell me more about the error.

It's called sandboxel on my profile check the sand file

init = function()
  mapg = maps["map2"]
  posX = 0
  posY = 0
end


update = function()
  randomsand = random.nextInt(2)
  print(randomsand)
  sand(mapg, posX, posY, randomsand)
  // xposition
  posX += 1
  if posX > 23 then
    posX = 0
    posY += 1
  end
  //ypos
  if posY > 23 then
    posX = 0
    posY = 0
  end
end 

draw = function()
  screen.drawMap(mapg,0,0,300,200)
  screen.drawText(system.fps,100,50,20,"rgb(255,255,255)")
end
sand = function( map, x, y, rng )
  local mapp = map.get( x, y )
  local mapD = map.get( x, y-1 )
  local mapLD = map.get( x-1, y-1)
  local mapRD = map.get( x+1, y-1)
  local drop = false

  //sand fall
  if mapp == "sand"  and mapD == "background" then
    
    map.set( x, y - 1,"sand")
    map.set( x, y,"background")
    drop = true
  end
  
  if drop == false and mapp == "sand" and ( mapLD =="background" or mapRD == "background") then
    if rng == 0 then
  //sand left
      if mapp == "sand" and mapLD == "background"  then
        map.set(posX-1,posY-1,"sand")
        map.set(posX,posY,"background")
      end
      else
      //sand right
      if mapp == "sand" and mapRD == "background"  then
        map.set(posX+1,posY-1,"sand")
        map.set(posX,posY,"background")
      end
      // integer end
    end
  end

end  // function end

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community