🏰 FA1 & FA2: SpaceKingdom + Interaction Design

Author: Anika Seksaria Sprint: 6

Portfolio Navigation

🏠 Main Portfolio | 📝 Homework Lessons | 🐺 Red Riding Hood


🌌 FA1 — SpaceKingdom Environment

FA1 introduced the OCS GameEngine through SpaceKingdom, an exploration level built around a background and sprite.

Configured Objects

Object Class Role
Background Background Sky Kingdom sky
Player Astro User-controlled character
NPC Astronaut1 Stationary guide NPC
Barrier dbarrier_1 Physical collision boundary

Engineering Decisions

  • Movement Physics: Set STEP_FACTOR to 1000 to simulate low-gravity movement
  • Positioning: Player initialized at (100, 300), NPC at (500, 300) intially
  • Scaling: Player SCALE_FACTOR set to 5, NPC set to 4
  • Collision Mapping: Barrier set with fromOverlay: true to correctly map the physics layer to the visual overlay (dragon)

Key Code: The Game Loop

// Iteration — updates every object each frame
gameObjects.forEach(obj => {
    obj.update(); // recalculates position using STEP_FACTOR
    obj.draw();   // renders to canvas
});

🐺 FA2 — Interaction & NPC Design

FA2 added interaction mechanics on top of FA1. I upgraded the static Astronaut1 NPC into an interactive character using proximity-based reactions.

What I Built

  • Hitbox: Started at 0.0 as a decorative baseline, then tuned using GameBuilder to create an interaction zone
  • Detection: reaction() method triggered when player enters NPC range using a Boolean Expression
  • State Management: NPC transitions between idle and interactive states based on player proximity and inventory

Key Code: Detection vs Reaction

// Nested conditions — 3 levels deep
handleCollision(other, direction) {
    if (other.type === "Player") {           // condition: type check
        if (this.distanceTo(other) < 50) {   // nested: proximity check
            if (player.hasItem("basket")) {  
                this.reaction("friendly");
            } else {
                this.reaction("hostile");
            }
        }
    }
}

📊 Rubric Coverage: FA1 & FA2

CS111 Topic FA1 Evidence FA2 Evidence
Numbers STEP_FACTOR: 1000, SCALE_FACTOR: 5 hitbox.range as Number
Strings Cloud texture paths NPC state "friendly" / "hostile"
Booleans fromOverlay: true isColliding flag
Arrays Asset collection lists gameObjects forEach loop
JSON Objects Object property literals NPC configuration object
Mathematical Ops position += velocity Distance calculations
Boolean Expressions if (isColliding && direction) distanceTo() < range
Iteration forEach over game objects map() / filter() for state
Conditions fromOverlay truthy check Player type detection
Nested Conditions Physics mapping logic Type + range + inventory check
Canvas I/O draw() 60fps cycle Real-time coordinate rendering
Classes Background, Barrier Wolf/Astro1 extends Character

Anika Seksaria · CSSE Sprint 6 · Spring 2026 · Mira Costa CS 111 · GameEngine v1.1