Week 9 Creative Switch – Khalifa Alshamsi

Concept:

In an endeavor to merge the timeless charm of LEGO with the dynamic glow of LED lighting, I took on a project that tested my creativity and also my persistence. The challenge was clear: integrate an LED system within a LEGO car in a functional and aesthetically pleasing manner. After numerous attempts and exploring various configurations, I found the perfect harmony by positioning the LED as the car’s internal dome light. This strategic placement allowed me to achieve an interactive feature where the light automatically turns on as the door closes and dims when the door is left open.

Code:

int ledPin = 9;           // LED connected to digital pin 9
int doorSensorPin = 2;    // Sensor (wires touching) connected to pin 2
int doorState = 0;        // Variable for reading the sensor status

void setup() {
  pinMode(ledPin, OUTPUT);      // Sets the digital pin as output
  pinMode(doorSensorPin, INPUT); // Sets the digital pin as input
  digitalWrite(doorSensorPin, LOW); // Enables pull-down resistor
}

void loop(){
  doorState = digitalRead(doorSensorPin); // Reads the state of the sensor value
  if (doorState == HIGH) {
     digitalWrite(ledPin, LOW);   // Turns LED off when the door is closed (wires touching)
  } else {
     digitalWrite(ledPin, HIGH);  // Turns LED on when the door is open (wires not touching)
  }
}

Video of Project:

Reflection and ideas for future work or improvements:

As I look back on this complicated project for me, I recognize the journey was as enlightening as it was challenging. One significant area for improvement that stands out is the need for a more refined wiring management system. Despite the project’s success, the sight of exposed wires and adhesive tape detracts from the overall aesthetic appeal. In future iterations, prioritizing a sleeker integration of the electronics will hopefully enhance the design.

Furthermore, this project served as a profound learning curve. Despite consuming countless videos and undergoing a trial-and-error process that saw me revising the wiring and code more times than I can count, I confess there remains a haze around my understanding of the underlying electronics principles. This realization, far from discouraging me, has sparked a curiosity to delve deeper into the fundamentals of electronics and programming.

Looking Ahead:

This project has laid the groundwork for further exploration into the fusion of technology with traditional toys. Ideas for future projects include incorporating more interactive elements, such as sound effects synchronized with the door’s motion or ambient light sensors to activate the headlights in dim conditions, transforming the LEGO car into an even more immersive and interactive experience, maybe even fully coding a 3D printed one to drive using the Arduino but again I still don’t know the full stretch of an Arduino board.

In essence, this journey has not only expanded my technical skills but also opened up a scenery of possibilities for exploring.

Week 8a Reading – Khalifa AlShamsi

Hamilton’s journey and the obstacles she faced, especially in an era when the field of software engineering was in its infancy (and dominated by men), is both inspiring and enlightening. The concept of “software” as crucial to the Apollo missions’ success was not just innovative; it was revolutionary. Her approach to creating error-preventing code that could literally handle unknowns in real-time was not only ahead of its time but also a critical factor in the success of landing humans on the moon and safely bringing them back to Earth.

One of the most eye-opening aspects of Hamilton’s story is the realization that the meticulous, problem-solving mindset required for such a monumental task came from someone who was largely self-taught in the field. It challenges the conventional wisdom about the pathways to innovation and highlights the importance of determination, intellectual curiosity, and the courage to venture into uncharted territories.

On the other hand while exploring Don Norman’s insights on the principle that “attractive things work better” has profoundly shifted my perspective on the aesthetics and functionality of objects around me. It’s a revelation to understand that the visual appeal of an object isn’t just about its looks but significantly influences its usability and, by extension, our efficiency and mood. This concept throws light on the many moments of interaction with tools and environments that are supposed to aid in learning and productivity but sometimes end up doing the opposite.

Norman’s discussion on how aesthetics can enhance functionality resonates deeply. It’s not merely about making objects or interfaces pleasing to the eye but about enhancing their effectiveness through design. This insight challenges the often-held belief that beauty and utility stand at odds, underscoring instead that they can, and ideally should, complement each other. This strikes a chord, considering the countless times I’ve grappled with study tools or campus interfaces that are functional but uninspiring or, worse, visually appealing but confusing to navigate.

The realization that our emotional response to an object’s design can significantly impact our engagement and performance illuminates the everyday design choices surrounding us. Norman’s argument has sparked a newfound curiosity in me to scrutinize the tools and spaces I interact with daily, from the elegance of a well-crafted note-taking app to the practical layout of a student lounge. It emphasizes the rarity of experiencing truly harmonious design, where form and function are in perfect alignment, enhancing both usability and delight.

This exploration of the intersection between aesthetic appeal and functional design has not only heightened my awareness of the design choices that shape our everyday experiences but also instilled an appreciation for thoughtfully designed objects and environments. It underscores the potential for design to transform mundane interactions into moments of joy and efficiency, urging a more critical and appreciative lens towards the designed world around us.

MidTerm Project – Khalifa Alshamsi

Concept and Gameplay

“UFO Escape” transports players into the role of a UFO pilot tasked with the critical mission of avoiding collision with perilously floating rocks in space. The game unfolds across a dynamic background that transitions from the tranquility of space to the adrenaline-pumping danger zone filled with obstacles. Players must use the arrow keys to maneuver their spacecraft, navigating the challenging asteroid field. Each successful dodge rewards the player with points, elevating the stakes and the satisfaction derived from setting new high scores.

Technical Achievements and Design Decisions

In my opinion, one of the game’s standout features is its seamless integration of visual and auditory elements to create an immersive experience, which was the vibe I was going for. The use of distinct background images for different game states — a peaceful space scene for the menu and game over screens and a more in-the-field backdrop for gameplay.

// Displays the space background image only during menu and game over states but displays a different image during gameplay
if (gameState === "MENU" || gameState === "GAME OVER") {
  background(bgImage);
} else if (gameState === "PLAYING") {
  background(gameplayBgImage);
}

The transition between these states is goofy because of its old-school UFO soundtrack that loops during gameplay. This adds a layer of nostalgia that brings me back to the old free online games I used to play growing up in school using the school computers. The soundtrack then abruptly halts upon the game’s end, marking the player’s failure and the game’s conclusion.

Another area of pride would be collision detection, which not only ensures that the game is playable but also maintains a level of difficulty that is engaging without being frustrating, but it was highly frustrating to tune it properly to respond.

// Function to detect collision with obstacles
collidesWith(obstacle) {
  let closestX = constrain(obstacle.x, this.x - this.width / 3, this.x + this.width / 3);
  let closestY = constrain(obstacle.y, this.y - this.height / 3, this.y + this.height / 3);
  let distanceX = obstacle.x - closestX;
  let distanceY = obstacle.y - closestY;
  let distanceSquared = (distanceX * distanceX) + (distanceY * distanceY);
  return distanceSquared < (obstacle.radius * obstacle.radius); // Checks if distance is less than obstacle radius
}

The game accurately determines collisions by calculating the closest points between the UFO and the incoming asteroids. This method considers the actual positions and dimensions of both objects, offering a realistic and, for the most part, precise detection mechanism that enhances the player’s experience.

Areas for Improvement and Challenges

While “UFO Escape” is the first game I got to create, and I am extremely proud of it, certain aspects remain ripe for enhancement. The collision detection system, though effective, could be refined to accommodate the irregular shapes of the rocks more accurately.

Another challenge faced during development was ensuring the game’s performance remained smooth despite the increasing number of obstacles. This issue kept bugging the game, making the rocks not properly collide with the UFO ship. This issue was largely mitigated through optimization techniques, such as removing off-screen obstacles from the array to free up resources.

Conclusion

“UFO Escape” embodies the spirit of classic arcade games, but I would say with a bit more graphics. Its development journey was filled with learning opportunities, from refining collision detection algorithms so many times that I lost count to creating an engaging user interface.

Sketch:

Script:

// Variables for game assets
let bgImage; // Variable to hold the background image for menu and game over screens
let bgMusic; // Variable to hold the background music for gameplay
let player; // Player object
let obstacles = []; // Array to store obstacles
let gameSpeed = 6; // Speed at which obstacles move
let score = 0; // Player's score
let gameState = "MENU"; // Initial game state; that is "MENU", "PLAYING", or "GAME OVER"
let rockImage; // Variable to hold the rock image

// Preload function to load game assets before the game starts
function preload() {
  bgImage = loadImage('space.png'); // Loads the background image
    gameplayBgImage = loadImage('gameplay.jpg'); // Loads the gameplay background image
  bgMusic = loadSound('gameplaysound.mp3'); // Loads the background music
  rockImage = loadImage('rock-2.png'); // Loads the rock image
}

// The setup function to initialize the game
function setup() {
  createCanvas(400, 600); // Size of the game canvas
  player = new Player(); // Initializes the player object
  textAlign(CENTER, CENTER); // Setting text alignment for drawing text
}

// Draw function called repeatedly to render the game
function draw() {
  // Displays the space background image only during menu and game over states but displays a different image during gameplay
  if (gameState === "MENU" || gameState === "GAME OVER") {
    background(bgImage);
  } else if (gameState === "PLAYING") {
    background(gameplayBgImage);
  }

  // Handles game state transitions
  if (gameState === "MENU") {
    drawMenu();
  } else if (gameState === "PLAYING") {
    if (!bgMusic.isPlaying()) {
      bgMusic.loop(); // Looping the background music during gameplay
    }
    playGame();
  } else if (gameState === "GAME OVER") {
    bgMusic.stop(); // Stops the music on game over
    drawGameOver();
  }
}

// Function to display the game menu
function drawMenu() {
  fill(255,0 ,0);
  textSize(24);
  text("UFO Escape", width / 2, height / 2.5);
  textSize(16);
  fill(255);
  text("Avoid the rocks!\nUse ARROW KEYS to move\nPress ENTER to start", width / 2, height / 2);
}

// Function to handle gameplay logic
function playGame() {
  fill(255);
  textSize(16);
  text(`Score: ${score}`, width / 2, 30);

  player.show(); // Displays the player
  player.move(); // Moves the player based on key inputs

  // Adding a new obstacle at intervals
  if (frameCount % 120 == 0) {
    obstacles.push(new Obstacle());
  }

  // Updates and displays obstacles
  for (let i = obstacles.length - 1; i >= 0; i--) {
    obstacles[i].show();
    obstacles[i].update();
    // Checks for collisions
    if (player.collidesWith(obstacles[i])) {
      gameState = "GAME OVER";
    }
    // Removes obstacles that have moved off the screen and increment score
    if (obstacles[i].y > height) {
      obstacles.splice(i, 1);
      score++;
    }
  }
}

// Function to display the game over screen
function drawGameOver() {
  fill(255, 0, 0);
  textSize(32);
  text("Game Over", width / 2, height / 2);
  textSize(16);
  fill(255);
  text("Press ENTER to restart", width / 2, height / 2 + 40);
}

// Function to handle key presses
function keyPressed() {
  // Starts the game or restart after game over when ENTER is pressed
  if (keyCode === ENTER || keyCode === RETURN) {
    if (gameState === "MENU" || gameState === "GAME OVER") {
      gameState = "PLAYING";
      resetGame();
    }
  }
}

// Function to reset the game to its initial state
function resetGame() {
  obstacles = []; // Clear existing obstacles
  score = 0; // Reset score
  player = new Player(); // Reinitialize the player
}

// Player class
class Player {
  constructor() {
    this.width = 60; // Width of the UFO
    this.height = 30; // Height of the UFO
    this.x = width / 2; // Starting x position
    this.y = height - 100; // Starting y position
  }

  // Function to display the UFO
  show() {
    fill(255); // Sets color to white
    rectMode(CENTER);
    rect(this.x, this.y, this.width, this.height, 20); // Draws the UFO's body
    fill(255, 0, 0); // Sets the glass color to red
    arc(this.x, this.y - this.height / 4, this.width / 2, this.height / 1, PI, 0, CHORD); // Draws the glass
  }

  // Function to move the player based on arrow key inputs
  move() {
    if (keyIsDown(LEFT_ARROW)) {
      this.x -= 5; // Moves left
    }
    if (keyIsDown(RIGHT_ARROW)) {
      this.x += 5; // Moves right
    }
    if (keyIsDown(UP_ARROW)) {
      this.y -= 5; // Moves up
    }
    if (keyIsDown(DOWN_ARROW)) {
      this.y += 5; // Moves down
    }
    this.x = constrain(this.x, 0, width); // Keeps player within horizontal bounds
    this.y = constrain(this.y, 0, height); // Keep player within vertical bounds
    //This is only so the player cannot exist the canvas
  }

  // Function to detect collision with obstacles
  collidesWith(obstacle) {
    let closestX = constrain(obstacle.x, this.x - this.width / 3, this.x + this.width / 3);
    let closestY = constrain(obstacle.y, this.y - this.height / 3, this.y + this.height / 3);
    let distanceX = obstacle.x - closestX;
    let distanceY = obstacle.y - closestY;
    let distanceSquared = (distanceX * distanceX) + (distanceY * distanceY);
    return distanceSquared < (obstacle.radius * obstacle.radius); // Checks if distance is less than obstacle radius
  }
}

// Obstacle class
class Obstacle {
  constructor() {
    this.radius = random(15, 30); // Random radius for obstacle
    this.x = random(this.radius, width - this.radius); // Random x position
    this.y = -this.radius; // Starts off-screen so it looks like its coming towards you
  }

  // Function to display the rocks
  show() {
    image(rockImage, this.x, this.y, this.radius * 2, this.radius * 2); // Draws them as a circle
  }

  // Function to update obstacles position
  update() {
    this.y += gameSpeed; // Moves obstacles down the screen
  }
}

 

Week 5 Reading Response – Khalifa Alshamsi

The historical context provided, referencing Marvin Minsky’s underestimation of the complexity of computer vision, sets the stage for the discussion on how the field has evolved to include a wide array of applications, especially in the arts. The mention of Myron Krueger’s Videoplace as an early example of interactive artwork utilizing computer vision illustrates the potential for creative interaction between humans and computers beyond the conventional mouse and keyboard interfaces.

The exploration of projects such as Messa di Voce, Standards and Double Standards, Sorting Daemon, and others within the article showcased the versatility of computer vision in crafting interactive and immersive art experiences. These projects, each with its unique thematic focus, from surveillance and privacy to the nuanced exploration of human emotions via facial recognition, illustrate the breadth of computer vision’s applicability. They catalyzed my curiosity, pushing me to consider how technology can be leveraged to challenge societal norms, provoke thought, and evoke emotional responses.

Week 5 – Khalifa Alshamsi

For the midterm, I plan on creating a car racing game in which the objective is to get as many points as possible depending on how far you reach before colliding with a vehicle.

The Sketch:

Description:

The game uses a simple rectangular design so far until I can finish the game in more detail in which the white rectangle is your car and the blue rectangles are the other cars on the road and you aim to not collide with them.

Script:

let player;
let obstacles = [];
let gameSpeed = 2;

function setup() {
  createCanvas(400, 600);
  player = new Player();
}

function draw() {
  background(51);
  
  // Player
  player.show();
  player.move();
  
  // Obstacles
  if (frameCount % 120 == 0) { // Adds a new obstacle every 100 frames
    obstacles.push(new Obstacle());
  }
  
  for (let obs of obstacles) {
    obs.show();
    obs.update();
    
    // Checking for collision
    if (player.collidesWith(obs)) {
      noLoop(); // Stop the game
      textSize(32);
      textAlign(CENTER, CENTER);
      fill("White");
      text("Game Over", width / 2, height / 2);
    }
  }
}

// Player class
class Player {
  constructor() {
    this.size = 30;
    this.x = width / 2;
    this.y = height - this.size * 2;
  }

  show() {
    fill("white");
    rectMode(CENTER);
    rect(this.x, this.y, this.size, this.size);
  }

  move() {
    if (keyIsDown(LEFT_ARROW)) {
      this.x -= 5;
    } else if (keyIsDown(RIGHT_ARROW)) {
      this.x += 5;
    }
  }

  collidesWith(obstacle) {
    let hit = collideRectRect(this.x, this.y, this.size, this.size, obstacle.x, obstacle.y, obstacle.size, obstacle.size);
    return hit;
  }
}

// Obstacle class
class Obstacle {
  constructor() {
    this.size = random(20, 50);
    this.x = random(this.size, width - this.size);
    this.y = 0;
  }

  show() {
    fill("blue");
    rect(this.x, this.y, this.size, this.size);
  }

  update() {
    this.y += gameSpeed;
  }
}

// Function to check rectangular collision (Note to self p5.collide2D library needed)
function collideRectRect(x, y, w, h, x2, y2, w2, h2) {
  return x < x2 + w2 && x + w > x2 && y < y2 + h2 && y + h > y2;
}

Problems Encountered:

The problem that I faced the most was setting up the collision format, but I will, later on, be able to fix it by using a p5.collide2D library because, from my understatement, it will make the collision simpler and exact to the collision I want the game to run.

Future goals:

  1. Improved graphics: By using either a better code format for the cars instead of the rectangles or implementing pictures to represent the cars.
  2. Scoring system: The scoring system is yet to be implemented into the game but the idea is for it to score a higher number the further you reach in the game while avoiding collisions.
  3. Sound Effects:  Adding music to the background to add more to the game’s value while playing.
  4. Increased difficulty: Making gradual increases to the gameSpeed or the number of cars in the game to make it harder to continue.

 

Week 4 Reading Response – Khalifa Alshamsi

Reading “The Design of Everyday Things” by Don Norman has made me rethink my everyday frustrations with things like doors and appliances. It’s pretty eye-opening to see how common it is to struggle with objects that are supposed to be simple. The idea of “Norman doors” – doors that confuse you whether to push or pull – is something I can relate to. It turns out these annoyances aren’t just random; they’re often the result of poor design choices that don’t consider the user’s experience.

Norman talks a lot about the importance of making things intuitive, which makes sense. It’s frustrating to need signs or instructions for something as basic as a door. But the book also points out how often design prioritizes looks over functionality, leading to unnecessary complexity. This struck a chord with me because it’s not just about aesthetics; it’s about making things harder to use than needed.

The book has made me more aware of the design choices around me and sparked an interest in looking at everyday objects more critically. It’s one thing to appreciate good design when everything works smoothly, but Norman’s perspective has made me more conscious of how rare that is.

Week 4 Assignment – Khalifa Alshamsi

For this assignment, I drew my inspiration from the YouTube channel called “Short Coding Skills MoCCAモカ,” where he created a nice generative art style, but I could not understand the code he had.

A=97;
ATOZ=122-A+1;q=99;
draw=_=>{frameRate(10);
background(0,10);fill(200,0,0);
textSize(random(45));j=frameCount;
text(String.fromCharCode(j%30+A),noise(j)*q,noise(j+1)*q);         
         j= frameCount;text("*".repeat(ATOZ).split("").map((c,i)=>String.fromCharCode(i+A))[j%(ATOZ)],noise(j)*q,noise(j+1)*q)
}

So I took a shot at creating a similar feel to the one he made but instead it would say “STONKS,” because why not…

Sketch:

Description:

Randomized order of “STONKS”and random positioning where each selected letter is randomly displayed in different positions on the canvas.

Script:

let letters = "STONKS"; // Letters to be displayed
let displayDuration = 50; // How long to display each letter (in frames)
let nextChangeTime = 0; // When to change to the next letter

function setup() {
  createCanvas(640, 684);
  textSize(64);
  fill("grey"); // Set letter color to blue
  frameRate(60); // Set the frame rate
}

function draw() {
  if (frameCount >= nextChangeTime) {
    // Clear the background each time before displaying a new letter
    background(0);

    // Select a random letter from the string
    let letter = random(letters.split(""));
    
    // Pick a random position for the letter
    let x = random(width);
    let y = random(height);
    
    // Display the letter
    text(letter, x, y);
    
    // Set the time for the next change
    nextChangeTime = frameCount + displayDuration;
  }
}

Week 3 Reading Response – Khalifa Alshamsi

Reading “The Art of Interactive Design” by Chris Crawford has got me thinking about the many aspects of digital interaction, from the narrow scope of game design and conventional software development to the larger social and technical context. Among the many interesting, thought-provoking points brought up by Crawford, the essence of interaction was something I never really got to think about in the way Crawford brought it up. Crawford’s exploration of interaction as a conversation between the user and the system prompts a reconsideration of what effective communication means in a digital context. It makes me think about how devices, apps, and platforms are not just tools but participants in a dialogue with users. This perspective challenges designers to create more empathetic and responsive systems that genuinely understand and adapt to user needs, or else it becomes useless as if a person is speaking to you in a different language than the one you know.

 

Reflecting on “The Art of Interactive Design” inspires a personal commitment to lifelong learning in the field of technology. The pace of change is rapid, and staying informed about new theories, tools, and methodologies is essential for anyone interested in creating meaningful interactive experiences. It reinforces the importance of curiosity, creativity, and critical thinking in navigating the complexities of interactive design.

Week 3 Assignment – Khalifa Alshamsi

 

For this assignment, I drew inspiration from the rainfall in the UAE this past weekend, a truly cherished occurrence. Given my lack of color perception, I aimed to infuse this natural phenomenon with a vibrant spectrum of colors.

The Sketch:

Description:

The sketch simulates colorful raindrops falling against a light lavender background, which Is meant to be a blue-tinted window on a foggy morning; at least, that’s the color I see when I look at it. Each ‘raindrop’ object tracks its position, speed, and color. The raindrops reset once they fall off the bottom of the canvas, simulating a continuous rainfall.

Script:

// Defing the Raindrop's class 
class Raindrop {
  constructor() {
    this.x = random(width);
    this.y = 0; // Start from the top
    this.length = random(10, 20);
    this.speed = random(1, 5);
    this.color = color(random(255), random(255), random(255), 200); 
    // Semi-transparent
  }

  // Method to update raindrop properties for each frame
  fall() {
    this.y += this.speed;
    // Reset the drop when it goes off screen
    if (this.y > height) {
      this.y = 0;
      this.x = random(width);
      this.color = color(random(255), random(255), random(255), 200);
    }
  }

  // Method to draw the raindrop
  show() {
    stroke(this.color);
    line(this.x, this.y, this.x, this.y + this.length);
  }
}

let raindrops = []; // Array to hold Raindrop objects
const numDrops = 400; // Total number of raindrops

function setup() {
  createCanvas(640, 684);
  // Initialize raindrops
  for (let i = 0; i < numDrops; i++) {
    raindrops.push(new Raindrop());
  }
}

function draw() {
  background(230, 230, 250); // Light lavender background
  // Update and draw each raindrop
  raindrops.forEach(drop => {
    drop.fall();
    drop.show();
  });
}

Problems Encountered:

The challenge was ensuring the raindrops’ continuous flow and dynamic color changes without creating visual clutter. To address this, I implemented a reset mechanism for each raindrop once it fell off the screen and used semi-transparent colors to soften the visual impact.

Casey Reas Response – Khalifa Alshamsi

In the realm of art, I’ve always held the belief that meaning and visuals represent distinct aspects when appreciating art. My beliefs on the future of art invariably swerved towards visions of lights and interactivity, sidelining the pursuit of deeper meaning, and that is admitted, as I was ignorant of that aspect. However, my perspective was broadened during Casey Reas’s presentation. He introduced various artworks generated through algorithms, a concept that initially aligned with my thought process. Yet, it was his showcase of “Signals” that actually took me back. This piece, illustrating the interaction of protein cells within a cancer cell, not only expanded my appreciation of the intersection between technology and art but also underscored the profound potential for meaning in such intersections, bridging my gap in understanding and igniting a newfound appreciation for the depth of art’s potential.

 

Throughout the presentation, the only question that came to mind was whether any of these pieces of art match old artifacts regarding their value in terms of history. If, hypothetically, our civilization were to vanish overnight, leaving these modern creations as remnants for future generations to discover, how would they interpret them? Would they perceive these pieces as remnants of an extinct religion, or would they recognize them as artistic expressions? This question only comes to me because I wouldn’t personally understand any of it without reading the description or having someone explain what the artist meant by it.