hackclub / sprig

🍃 Learn to code by making games in a JavaScript web-based game editor.

Home Page:https://sprig.hackclub.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error not properly displaying when variable declared twice

Sheepy3 opened this issue · comments

Describe the bug
when I declared the variable master twice, the game would become a black screen and no error would be output.

const master = "m"
const sky = "b"
const solid = "s"
setLegend(
  [ master, bitmap`
....0.05550.....
......0...0.....
.....0....0.....
.....0...0......
......000.......
......0.0.......
.....00.00......
....00...00.....
....0.....0.....
....0.....0.....
....0.....0.....
....0.....0.....
....0.....0.....
....0.....0.....
...00.....00....
..00.......00...` ],
  [ follower, bitmap`
................
.....0000000....
....00.....00...
....0.......0...
....0.......0...
....0.......0...
....0.......0...
....0.......0...
....0.......0...
...00000000000..
.......000......
.......0.0......
......0..0......
......0...0.0...
....0003.30.0...
....0.0...000...` ],
  [ solid, bitmap`
4444444444444444
4444444444444444
44DD44D444444444
4DCCD4CD44DD444D
DCCCCDCCD4CCDDDC
CCCCCCCCCDCCCCCC
CCCCCCCCCCCCCCCC
CCC1LCCCCCC1LCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCC1LCC
CCCCCCCCCCCCCCCC
CC1LCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC`]
)

let master = {dx:0,dy:0}
let follower = {dx:0,dy:0}

//lets define our player as on object!
let actor = {x:3, y:3, sprite:"idle"};

setSolids([])

//With a map of 10x8 tiles, pixels are 1:1 with the display of the sprig!
const levels = [
  map`
...........
...........
...........
..f........
..m...sss..
...........
...........
sssssssssss`
]

function updatesprite(){
console.log(actor.x)

}

setMap(levels[0])

onInput("w", () => {
  actor.y+=1  
})
onInput("a", () => {
  actor.x-=1
})
onInput("s", () => {
  actor.y-=1
})
onInput("d", () => {
  actor.x+=1
})

afterInput(() => {
  updatesprite()  
})

To Reproduce
Steps to reproduce the behavior:

  1. declare variable as sprite key
  2. declare variable as object with properties
  3. attempt to run game

Expected behavior
a error should be displayed at the bottom of the code area.

Actual behavior
error only displays in console, which is 1. not inherently expected to be open and 2. isn't accessible on locked down school computeers
Screenshots

image

could reproduce with

const master = "something"
let master = "some other thing"