Superpowers Game Development Series #5

SUPER PACMAN

Chapter 11 : Polishing the game

We can add the sounds and music in the different part of our code.

Global Script
[...]
namespace Global {
  [...]
  export function startNewGame(){
  [...]
    Sup.Audio.playSound("Sounds/Music");
[...]
Game Script
[...]
  update() {
  [...] 
    if(Global.coins.small === 0 && Global.coins.big === 0){
      Sup.Audio.playSound("Sounds/Music");
[...]
[...]
  update() {
  [...]
    if(hitButton.length > 0){
      [...]
      if(Sup.Input.wasMouseButtonJustPressed(0)){
        Sup.Audio.playSound("Sounds/MenuButton");
[...]
Pacman Script
[...]
  getCoinAt(column:number, row:number){
    for(let coin of Global.coinsList.small){
      if(coin.getX() === column && coin.getY() === row){
        Sup.Audio.playSound("Sounds/EatCoin");
[...]
  getBigcoinAt(column:number, row:number){
    for (let bigcoin of Global.coinsList.big) {
      if (bigcoin.getX() === column && bigcoin.getY() === row) {
        Sup.Audio.playSound("Sounds/EatBigCoin");
[...]
  getFruitAt(column:number, row:number){
    for (let fruit of Global.fruits){
      if(fruit.position.x === column && fruit.position.y === row){
        Sup.Audio.playSound("Sounds/EatFruit");
[...]
Ghost Script
[...]
  update() {
    if (Math.abs(this.position.x/10 - Global.pacman.position.x) < 5 && Math.abs(this.position.y/10 - Global.pacman.position.y) < 5){
      if(this.vulnerable){
        Sup.Audio.playSound("Sounds/EatGhost");
        [...]
      }
      if(!this.vulnerable){
        Sup.Audio.playSound("Sounds/PacmanDeath");
        Sup.setTimeout(1000, function(){Sup.Audio.playSound("Sounds/Music")});
[...]

We can download the superpowers project finale from here.

<-- go to chapter 10 -- go to chapter 12 -->