SLC21 Week5 - Programming Games&Puzzles

in #slc21w5sergeyk20 days ago
1000222553.png
Canvas

edges Make the field longer, put ( в init()) on the edges, for example, of a pillar - #at a random distance of 0-2 from the edges of the map (field). The player must move between these pillars.

Pillars are what we will need to implement this. We will programmatically generate pillars near (close to) the edges of the map within a random distance of 0 - 2 units. Here in this program, a grid-based map is what I have used to demonstrate how we can place these pillars.

1000222508.gif


Interpretation

  • The Initialisation (_init_) creates a grid-based field with specified height and width.

  • The place_pillars Iterates over the edges of the field left, right, top, and bottom. Randomly decides whether to place a pillar (P) at each position with a random 0 - 2 unit distance from the edges.

  • The print_map is what visualizes the field with pillars.

In summary, the approach that we have applied ensures that the pillars are randomly placed but remain near the edge 0 - 2 distance which we can as well adjust the logic the way we can to fit our specific games.


Puddles Complete the first task, make the field even longer, and randomly place puddles on the field _. The player has to pass through these puddles without obstacles, only to change his appearance to %a wet player.

Here we have programmed an extended version of the first code, now incorporating puddles. In this code, the player must navigate through the field, encountering puddles that make them appear as a "wet player" when stepped on. Hahaha it is funny right

1000222509.gif


Interpretation

Here the key features are

  • Longer field in which the map is initialized with larger dimensions. For example a dimensions of 30× 15 for a more expansive play area.

  • Puddles (~): puddles are placed on the field randomly ensuring they don't overlap with pillars.

  • Player Interaction: Player is presented by @

  • Moves using left, right, up, and down commands.

  • Steps into puddles change the player status to "wet.

  • Block movement is player (P) and the field updates dynamically as the player moves.


jump Add a jump (spacebar) - the player jumps one cell in the direction of his movement!!!

Here I have done an updated version of the game logic to include a jump feature. If a player presses the spacebar they would be allowed to jump one cell I'm their current direction as seen below.

1000222511.gif

Interpretation

In this program the key features are;

  • Jump Mechanic allows the players to jump two cells in the direction they moved by typing "jump". If players haven't moved yet, the game will remind them to move first.

  • Dynamic Map Updates: With allow jumping over obstacles like pillars is not allowed. Landing on a puddle updates the player's status to wet.

  • Player State: 'last_direction` keeps track of the player's most recent movement direction, enabling the jump.

Commands:

  • jump The player jumps two cells to the right.
  • Right The player moves right.

Puddle disappears If the player jumps (through the space) into a single puddle - it dries up, when the player simply runs through the puddle - it does not dry up.

Here also, I have done an updated version of the code where puddles disappear (dry up) if the player jumps into them, but they remain if the player simply runs through them which we can see below.

1000222512.gif


Interpretation

In this program, the key features are;

  • Puddle Drying If the player jumps into a puddle using jump< the puddle will disappear (~ becomes a blank space). The puddle remains if the player simply runs through it.

  • Interactive Feedback: The game notifies the player when they step into a puddle and if the puddle dries up.

  • Updated Puddle List: When a puddle dries up, it's removed from the puddles list.

Commands:

  • jump The player jumps over two cells and lands on a puddle.
  • Right The player moves right to an empty cell leaving the status dry

Stones Complete the first task, make the field even longer, and randomly place stones on the field. The player cannot cross these stones but must cross these stones.

Here I have developed an updated version of the code where stones (a) are added to the field. The stones are obstacles that the player cannot move through and must find a way around which you can see below.

1000222513.gif

Interpretation

In this program, the key features are;

  • Stones (a): Stones are the obstacles placed randomly on the field. Player cannot move through or onto stones, as the movement is blocked.

  • Larger Map: Field size increased to allow more space for stones and strategic movement.

  • Interactive Feedback: The Game alerts the player if they attempt to move into a stone or other pillars (obstacle).

Commands:

  • jump The player jumps over a space or puddle
  • Right The player moves to the right.
  • up The player encounters a stone and is blocked.

Statistics Add statistics: - number of moves, jumps, puddles, stones.

Here is an updated version of the game with statistics tracking. This game keeps count of the following

  • Number of moves: Each time the player moves, regardless of the direction.

  • Number of jumps: Every time the jumps using the jump command.

  • Puddles stepped into This tracks the number of puddles the player steps into

  • Obstacles encountered: this tracks the number of times the player tries to move into pillars or stones.

1000222514.gif

Interpretation

In this game, the key features are;

  • Statistics Tracking: moves which clings all player movements including jumps. jump; counts jumps explicitly. puddles_stepped which tracks how many puddles the player has stepped into. obstacles_encountered counts failed movement attempts due to pillars or stones.

  • Real Time Display: Statistics are printed after every move, so the player can be able to see their progress instantly.

Commands

Statisticsrightupjump
Moves112
Jumps001
Puddles stepped000
Obstacles encountered011

Push A player can push one stone, no more.

Here I have written an update code where the player can push one stone but only once during the game. In the game, the stone moves one cell in the direction the player pushes it, and the player cannot push more stones afterward as seen below.

1000222507.gif

Interpretation

In this program, the key features are;

  • Stone Pushing: The player can push one stone to an adjacent space. Also, after pushing one stone, no more stones can be pushed.

  • Updated statistics: stones_pushed tracks how many stones were pushed since the maximum is 1 and displays whether the players can still push a stone.

  • Validation: Stones cannot be pushed into another obstacle and also stones cannot be pushed outside the map.

Commands:

  • Up The player attempts to push a stone successfully.

  • Right The player moves right.


I am inviting; @kouba01, @simonmwigwe, and @ruthjoe

Cc:-
@sergeyk

Sort:  

The answer is NOT COUNTED
This does not correspond to the task at all. The task does not have any up/down directions, only left-right. Everything is much simpler. There should not be two-dimensional arrays here.
This is an attempt to solve the task completely not based on the given material.
Made in Python, the gif is a demonstration of the code - not the game process

Okay sir. That should be done better next time.