💀
Adam Cleave
  • 💀Adam Cleave's A-Level Project
  • 📖Reference Page
  • 🖊️1 Analysis
    • 1.1 Problem Identification
    • 1.2 Stakeholders
    • 1.3 Research
    • 1.4a Features of Proposed Solution
    • 1.4b Computational Methods
    • 1.5 Success Criteria
    • 1.6 Hardware and Software Requirements
  • 🎨2 Design and Development
    • 2.1 Design Frame
    • 2.2.1 Cycle 1 - Player and Boundaries
    • 2.2.2 Cycle 2 - Movement
    • 2.2.3 Cycle 3 - Jumping and Perspective
    • 2.2.4 Cycle 4 - First Level
    • 2.2.5 Cycle 5 - Grunts
    • 2.2.6 Cycle 6 - Level Change
    • 2.2.7 Cycle 7 - Second Level
    • 2.2.8 Cycle 8 - Background Music
    • 2.2.9 Cycle 9 - Twines
  • 👨‍🔬3 Testing
    • 3.1 Testing for Function and Robustness
    • 3.2 Usability Testing
    • 3.3 Checking Development Tests
  • 📄4 Evaluation
    • 4.1 Evaluation of Success Criteria
    • 4.2 Evaluation of Usability Features
    • 4.3 Maintenance and Future Development
Powered by GitBook
On this page
  • Design:
  • Objectives
  • Usability Features
  • Key Variables
  • Pseudocode
  • Development:
  • Outcome
  • Challenges
  • Testing:
  • Tests
  • Evidence
  1. 2 Design and Development

2.2.5 Cycle 5 - Grunts

Previous2.2.4 Cycle 4 - First LevelNext2.2.6 Cycle 6 - Level Change

Last updated 1 year ago

Design:

Objectives

In the fifth cycle, my objectives are to implement hostile enemies into the game. For now, I will only be adding the Grunt as detailed in . At this point, the Grunts don't need to be too detailed, a simple shape or image will do.

Usability Features

The Player will have to avoid the Grunts since they will cause the Player to die and the game to end. This will add excitement to the game since there is now a risk factor.

Key Variables

Variable Name
Use

FALL_DEATH

Determines the 'y value' for death when the Player's character is falling.

Pseudocode

The pseudocode for the hostile Grunts is shown below:

// Grunts

// Custom component controlling enemy patrol movement
function patrol(speed = 60, dir = 1):
    return {
        id: "patrol",
        require: [ "pos", "area" ],
        add():
            this.on("collide", (obj, col) =>
                if (col.isLeft() or col.isRight()):
                    dir = -dir
                end if
            )
        end add

        update():
            this.move(speed * dir, 0)
        end update
    }
end function

// DEATH and DANGER

// Grunts
player.onCollide("enemy", (e, col) =>
    // if it's not from the top, die
    if (not col.isBottom()):
        go("lose")
        alert("You died! Please try again!")
        // Refresh the page
        if (player.pos.y > FALL_DEATH):
            window.location.reload()
        else:
            window.location.href = "https://a-level-project.adamcleave.repl.co"
        end if
    end if
end function

Development:

Outcome

  • The player is now faced with the Grunt opponents when the game begins, the code for this can be viewed below:

// Grunts

// Custom component controlling enemy patrol movement
function patrol(speed = 60, dir = 1) {
	return {
		id: "patrol",
		require: [ "pos", "area" ],
		add() {
			this.on("collide", (obj, col) => {
				if (col.isLeft() || col.isRight()) {
					dir = -dir
				}
			})
		},
		update() {
			this.move(speed * dir, 0)
		},
	}
}

// DEATH and DANGER

// Grunts
player.onCollide("enemy", (e, col) => {
  // if it's not from the top, die
  if (!col.isBottom()) {
    go("lose");
    alert("You died! Please try again!");
    // Refresh the page
    if (player.pos.y > FALL_DEATH) {
      window.location.reload();
    } else {
      window.location.href = "https://a-level-project.adamcleave.repl.co";
    }
  }
});

Challenges

Some challenges I faced during this cycle:

  • The Grunts movement was difficult to implement because they wouldn't comply with the gravity which was set.

Testing:

Tests performed in this cycle are evidenced below, they were a crucial aspect to my development.

Tests

Test
Instructions
What I expect
What actually happens
Pass/Fail

1

Run code.

The game to start, boundaries rendered, player and Grunt placed.

As expected

Pass

2

Collide the Player's character with the Grunt.

The Player loses the game and the game is reset.

As expected

Pass

Evidence

The screen recording below shows the rendered sprite after moving from its original position, it completes the following tasks for this cycle:

Add Grunts as specified in .

🎨
1.4a Features of Proposed Solution
1.4a Features of Proposed Solution
1.4a Features of Proposed Solution