Pretty new to MakeCoda Arcade, but I’m trying to make a corona simulator where there are 100 identical sprites (2x2 px blue dot) of type “healthy” and one sprite (2x2 px red dot) og type “sick”.

On overlap, I want the “sick” sprite to infect the “healty” sprite and change the type (and image) of this single sprite from “healthy” to “sick” (and blue to red).

I’ve managed to make an array of the healthy sprites, but all are infected when one gets infected.

The goal is to make students simulate the effects of social distancing, mass testing and things like this.

Thanks in advance, folks!

Here you go:

The issue was that in the overlap you were going through all of the sprites in the array of Frisk sprites and setting each to Syk; instead, you can just use the variable in the event, otherSprite, which corresponds to the Frisk sprite that is colliding with a Syk sprite. (I also combined the two loops into one because the array was unneeded at this point).

As a note, if you’re changing the kinds of the sprites, or changing the number of them (creating / destroying), you probably want to have the array of all {kind} sprites created in the event itself; otherwise, the array will be out of date (referencing what sprites were Frisk at the start, not what sprites are currently Frisk)

Also here’s a start on the likely next step; making it so only some percentage of the sprites are moving (in this case 20%):

You’ll probably want to add in some logic for making the collisions between sprites ‘bounce’ eachother, and also something to handle making sickness ‘go away’ after time (one easy ish way is with the sprite lifespan, which is found under the same dropdown as set x to 0; this is a time in milliseconds, and after that the sprite will be destroyed. Then you can use an on sprite of kind {Syk} destroyed, and create a new sprite and place it where the Syk sprite was when it got destroyed / give it the same velocity.)

Much appreciated!

You are spot on concerning the next steps, but will challenge students to discuss how to improve the modell and how the steps taken throughout society can be modelled. Was wondering how to simulate different degrees of testing and isolating sick patients. Maybe sick patients who get tested stop conpletely and are incased inn a wall of some sort. Maybe I’ll need your help againg at some point in the future.

Have played around in Arcade for a couple of days now, and never used arrays, so this was just perfect.

1 Like