Skip to content

Sprint 1 Technical Implementation

Heather Blakeway edited this page Sep 12, 2022 · 3 revisions

Link back to the main page

Spawning of Ranged Enemy

The current implementation to spawn a ranged enemy can be found in the create() section of ForestGameArea. To spawn the electric eel a while loop is run which contains an if loop checking for a position to spawn the enemy. If a position can not be found the loop is broken.

private void spawnElectricEelEnemy(){
    Entity ElectricEelEnemy = NPCFactory.createElectricEelEnemy(player);
    GridPoint2 minPos = new GridPoint2(0,0);
    GridPoint2 maxPos = terrain.getMapBounds(0);
    GridPoint2 randomPos = RandomUtils.random(minPos,maxPos);

    while (true){
      randomPos = RandomUtils.random(minPos,maxPos);
      if (this.entityMapping.wouldCollide(ElectricEelEnemy, randomPos.x, randomPos.y)
              ||entityMapping.isNearWater(randomPos.x, randomPos.y)) {
        continue;
      } else {
        break;
      }
    }
    spawnEntityAt(ElectricEelEnemy,randomPos,true,true);
  }

Creating framework for projectiles

public class ProjectileFactory {
    public static void createProjectile(Entity shooter, Entity target) {
        float x1 = shooter.getPosition().x;
        float y1 = shooter.getPosition().y;
        float x2 = target.getPosition().x;
        float y2 = target.getPosition().y;

        Vector2 Target = new Vector2(x2 - x1, y2 - y1);

        //Entity Projectile = makeProjectile();


    }

    private static Entity makeProjectile() {
        Entity projectile = new Entity()
                .addComponent(new TextureRenderComponent("images/ElectricEel.png"))
                .addComponent(new PhysicsComponent())
                .addComponent(new PhysicsMovementComponent())
                .addComponent(new ColliderComponent())
                .addComponent(new CombatStatsComponent(1,20))
                .addComponent(new TouchAttackComponent(PhysicsLayer.PLAYER, 0.2f));

        return projectile;
    }

    private ProjectileFactory() {
        throw new IllegalStateException("Instantiating static util class");
    }
}

Table of Contents

Home

How to Play

Introduction

Game Features

Main Character

Enemies
The Final Boss

Landscape Objects

Shop
Inventory
Achievements
Camera

Crystal

Infrastructure

Audio

User Interfaces Across All Pages
Juicy UI
User Interfaces Buildings
Guidebook
[Resource Management](Resource-Management)
Map
Day and Night Cycle
Unified Grid System (UGS)
Polishing

Game Engine

Getting Started

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally