App Lab and Chrome browser


#1

We are having issues with App Lab U3L20. When the students build the function for move player, it will only work in one direction on reset. I believe I’ve narrowed down the issue with chrome, because when I load the program on my machine using Firefox, it will work (it fails to work on my machine in chrome) However, all the students have Chromebooks and this is frustrating to them. Any known fixes for Chromebooks?


#2

Hi, is this for App Lab or Game Lab? Can you share the code by clicking the “Share” button and pasting the link here. We probably won’t be able to debug this without looking at the code.

Thanks,
Elizabeth


#3

Sorry, I meant Game Lab. And its the example solution for U3L20-12 (move left & right). It will work in Firefox, but not chrome.


#4

Can you share the project with us? Otherwise there is no way for us to know what’s going on.


#5

This is the code for the example of U3L20-12. It runs in Firefox (the left and right arrow), but will only work one way, one time in chrome. My chrome is up to date as of 2/22/2019

//Students should be using the counter pattern to change the player sprite’s

//x position based on whether the left or right arrow is pressed. This should

//be done inside the movePlayer function, not hard coded into the draw loop.

// Variables

var score = 0;

// Create Sprites

var cake = createSprite(350,200);

cake.setAnimation(“cake”);

var player = createSprite(200,200);

player.setAnimation(“alienWalkRight”);

var enemy1 = createSprite();

enemy1.setAnimation(“ladybug”);

setEnemy1();

enemy1.velocityX = 2;

var enemy2 = createSprite();

enemy2.setAnimation(“ladybug”);

setEnemy2();

enemy2.velocityX = 2;

function draw() {

// draw the background

gameBackground();

// update the sprites

enemiesTouchCake();

movePlayer();

displaceEnemies();

enemiesTouchWater();

showScore();

drawSprites();

}

// Functions

function gameBackground() {

noStroke();

background(color(0,100,255));

fill(color(100,100,100));

rect(0,150,400,100);

fill(color(80,80,80));

rect(0,140,400,10);

rect(0,250,400,10);

}

function enemiesTouchCake(){

if (enemy1.isTouching(cake)) {

setEnemy1();

score = score - 2;

}

if (enemy2.isTouching(cake)) {

setEnemy2();

score = score - 2;

}

}

function movePlayer(){

if (keyDown(“right”)) {

player.x = player.x + 3;

}

if (keyDown(“left”)) {

player.x = player.x - 3;

}

}

function displaceEnemies(){

}

function enemiesTouchWater(){

}

function showScore() {

fill(“white”);

textSize(20);

text(“Score”,20,20,200,100);

text(score,20,40,200,100);

}

function setEnemy1() {

enemy1.x = 0;

enemy1.y = randomNumber(150, 250);

}

function setEnemy2() {

enemy2.x = 0;

enemy2.y = randomNumber(150, 250);

}


#6

Margaret,

Thanks for sharing, but can you share the project so the team (and others!) can play around with it in the environment it was built for(with all the sprites and backgrounds)? To share: Click on the “Share” button in the top left corner and it should give you a URL. If not available, you might need to turn on sharing from the dashboard.

Thanks in advance and looking forward to solving this problem!

Brad


#7

Here is the shared link to U3L20-12. This is a remix of the examplar
https://studio.code.org/projects/gamelab/CZwoC1uAVSV9r6C2Ls00FP1lnOEFB6zCPv5fBx6Z8FE


#8

Hi Margaret,

I just tried the link you sent in Chrome, and it’s working for me. I’m not sure what could be causing the problem that you describe. Maybe some other people can try the link and see whether it’s working for them, too. If it’s just your class, we’ll probably have to dig into the specifics of our machine setup.

To be clear, even the exemplar is not working on your machine?

Elizabeth


#9

Here is a link from screen recording firefox. As soon as I run, I am using the left and right arrows. https://drive.google.com/file/d/1DxmDExQd3wPu8Nzzg_bEvVYe503vGCUz/view

This is the link from screen recording Chrome. I’m using the arrows left and right for the entire run https://drive.google.com/file/d/1aWbEuUIeKryGLo8A9oAP9KAti8kwmPDR/view