arcade.makecode

Mari belajar MakeCode Arcade di Microsoft, dengan motto bermain dan belajar, silakan klik disini

Review: Dodgey Duck

Making enemies spawn in random positions is a useful tool that helps with making games unique for each player, but it comes at a cost: sometimes, the randomization can lead to elements being weirdly positioned, or make them unable to interact with your character.

One approach to help mitigate this is to be picky about what locations the random elements of the game can be created at. In this case, the enemy sprites and collectibles will be aligned to different rows in the game.

Starter Code

Pay careful attention to the on update every that creates the projectile in this code, as it provides an outline for how the “row based” positioning of the sprite will be handled.

In particular, this comes from the set projectile y to section: instead of picking a random location on the screen, it picks one of 8 locations at random, each separated by 16 pixels (the height of the projectile image).

Additionally, note that this projectile will move faster as the game moves on: each time one moves off screen, the player scores points, and new ducks will move faster.