Lava Game
There’s a new game in the menu called “The Colosseum of Lava“. Here is an introduction to the game, in Neo’s own words:
How I got the idea
A few years ago, I made a game on Scratch called “The Walls are Poison.” I decided to try and remake that game, called “The Colosseum of Lava” (above). I replaced the poison with lava, and changed the way how it spread. Before it was a green line moving in a random direction every few seconds, now it’s more like a puddle. I wrote this game in HTML Javascript, and it took me 2 days to write it. The game is a 2 player game, and the goal is to be the last player to survive. You can shoot other players, except the game only allows you to attack the closest player. If you touch the lava, you start to take damage based on the transparency of the lava. If you run out of bullets, then pressing the shoot button while standing near lava will replenish your bullets, and take some lava away.
Challenges
I found out a way to detect collisions between a circle and a rectangle.
1. loop through 1 – n, where n is the number of points.
2. get the direction of that point with this formula:
1 2 3 |
var radians = (Math.PI / 180) * angle var dx = Math.sin(radians) var dy = Math.cos(radians) |
3. add these values to the circle and then round them down
1 2 3 4 5 |
var circleX = 10 var circleY = 10 var radius = 10 var px = Math.floor(dx) var py = Math.floor(dy) |
4. check if they are in the rectangle
1 2 3 4 5 |
if (isInSquare()) { do something } else { do something } |
or you can do this if checking with sprites:
1 2 3 4 5 6 7 8 |
var sizeX = square.sizeX / 2 var sizeY = square.sizeY / 2 if (x >= square.x - sizeX && x <= square.x + sizeX && y >= square.y - sizeY && x <= square.y + sizeY) { do something } else { do something } |
Filed under: Uncategorized - @ April 28, 2023 7:33 am