Wednesday, September 18, 2024

Car Collision Game: My Journey as a Developer


 

Car Collision Game: My Journey as a Developer



Project: Car Collision Game
Developer & Designer: Amira Sayed Mohamed Ali

The Road to Inspiration 🚗💥

Every project begins with a spark of inspiration, and for me, it came from my deep love for arcade-style racing games. As a gamer and developer, I wanted to create something simple, fun, and packed with fast-paced action that would challenge players’ reflexes and timing. The idea of dodging obstacles at high speeds intrigued me, and I knew it would be an excellent way to hone my skills in game development, particularly in object collision detection—a crucial aspect of building interactive games.

My goal was to build a game where the player controls a car and must avoid obstacles to survive, with each crash bringing the player closer to a "Game Over" screen. The journey to develop this project was a thrilling learning experience that allowed me to combine my love for gaming and programming.


The Engine of the Game 🛠️

Technology Stack:

  • Python 🐍 - The programming language I used to bring the game to life.
  • Pygame 🎮 - A cross-platform library for game development, which allowed me to handle everything from graphics to sound.

At the heart of this project was the game engine I built to manage core functionalities:

  • Game Loops: Ensured smooth rendering and controlled how objects (like cars and obstacles) moved across the screen.
  • Collision Detection: Monitored interactions between the player's car and obstacles, determining when a crash occurred.
  • Game Over Mechanism: Tracked the number of collisions and ended the game once the player reached the crash limit.

The Development Process 🚧

The development of this game happened in phases, each introducing new features while improving upon previous iterations.

Week 1: Initial Setup & Designing the Game Interface
I started with the basics: setting up the Pygame environment and designing the game interface. It was important to get a feel for how the game would look, so I spent time designing the car, road, and obstacles.

Week 2: Implementing Player Controls & Obstacles
Once the visuals were ready, I implemented the player’s car controls. Ensuring responsive, smooth movement was crucial to the gameplay experience, and I spent time fine-tuning the controls for natural feel. I also created random obstacles that the player would need to avoid.

Week 3: Collision Detection & Game Over Mechanism
This week was all about adding the collision detection system. Pygame's collision detection capabilities allowed me to detect when the player's car hit an obstacle. However, the first version was too sensitive, registering crashes even when the car barely touched the edge of the obstacle. I had to tweak the algorithm to count collisions only when the car and obstacle fully collided.
Once I had this working, I implemented a game-over system that ended the game after a set number of collisions.

Week 4: Testing and Final Adjustments
This final phase involved testing the game for bugs and refining the gameplay experience. I focused on balancing the difficulty and ensuring smooth gameplay. Adjustments included fixing timing issues and making the car movement smoother by adjusting the frame rate.


Challenges & Lessons Learned 📚

The development process came with its fair share of challenges. Here’s a breakdown of the key obstacles I faced and how I overcame them:

Challenge 1: Collision Detection Sensitivity
Initially, the collision detection system was too sensitive, causing the game to end prematurely. The challenge was getting the algorithm to detect meaningful collisions rather than minor contact. After several adjustments, I improved the system so that only full crashes between the player's car and an obstacle would trigger a game over. This gave the game a more polished feel.

Challenge 2: Player Car Blinking Post-Crash
One of the more tricky aspects of the game was making the car blink after a crash to indicate the hit visually. Managing the timing so that the car would blink without disrupting gameplay was a complex task. I solved it by introducing a timer that tracked when the car should blink and when it should return to normal.

Challenge 3: Smooth Movement
At first, the car’s movement was jerky, making it hard for players to control it accurately. I fixed this by adjusting the frame rate and reducing the movement increments, leading to a smoother and more enjoyable gameplay experience.


Final Thoughts: A Deeper Dive into Game Development 🎮

Developing the Car Collision Game gave me invaluable insights into the complexities of game development. Handling game loops, designing object movements, and building a robust collision detection system were key learning experiences. My skills in Python and Pygame improved drastically, especially as I explored more about 2D graphics programming and real-time interaction.

While the game itself is simple, the lessons I learned throughout the development process were anything but. The attention to detail required to make the gameplay smooth and the satisfaction of overcoming technical challenges were incredibly rewarding. This project has deepened my passion for game development, and I’m excited to see where these newfound skills take me in future endeavors.


Moving Forward 🚀

This project is just the beginning of my journey into game development. My work on the Car Collision Game has laid the foundation for future projects, and I plan to dive deeper into more advanced topics like AI for non-player characters (NPCs) and more complex physics engines. I’m eager to continue learning, creating, and growing as a developer.

If you'd like to check out the game or my other projects, feel free to visit my GitHub or reach out on LinkedIn.

Stay tuned for more!


Amira Sayed Mohamed Ali
Sole Developer and Designer

Wednesday, July 17, 2024

What Happens When You Type https://www.google.com in Your Browser and Press Enter

 

What Happens When You Type https://www.google.com in Your Browser and Press Enter
What happens when you type Google in a web browser address bar and press  enter? - Quora

Understanding the process that takes place when you enter a URL into your browser is crucial for any software engineer. This post will walk you through the journey of a web request from your browser to the server and back, covering key components like DNS, TCP/IP, Firewalls, HTTPS/SSL, Load Balancers, Web Servers, Application Servers, and Databases.

1. DNS Request
DNS servers: what they are and how they ...

Domain Name System (DNS) is like the phonebook of the internet. When you type https://www.google.com, the browser needs to translate this human-readable domain into an IP address that machines understand.

  1. Browser Cache: First, the browser checks its cache to see if it has recently visited https://www.google.com and stored the corresponding IP address.
  2. OS Cache: If the browser cache is empty, the browser asks the operating system, which also has a DNS cache.
  3. Router Cache: If the OS cache is empty, the request moves to your router, which might also have a cache.
  4. ISP DNS Server: If the router doesn’t have the record, the request goes to the ISP’s DNS server.
  5. Recursive Search: If the ISP’s DNS server doesn’t know, it starts a recursive search, querying other DNS servers until it finds the authoritative DNS server for google.com, which provides the IP address.

2. TCP/IP
TCP/IP Model - GeeksforGeeks

Once the IP address is found, the browser needs to establish a connection to the server using the Transmission Control Protocol (TCP) and Internet Protocol (IP).

  1. TCP Handshake: A TCP connection is established using a three-way handshake:
    • SYN: The browser sends a SYN (synchronize) packet to the server to initiate the connection.
    • SYN-ACK: The server responds with a SYN-ACK (synchronize-acknowledge) packet.
    • ACK: The browser sends an ACK (acknowledge) packet back to the server, and the connection is established.
  2. IP Routing: Data packets are routed through various intermediate routers to reach the destination server.

3. Firewall
How Firewalls Work | HowStuffWorks

Firewalls are security systems that monitor and control incoming and outgoing network traffic based on predetermined security rules. Both your device and the server have firewalls.

  1. Client-side Firewall: Ensures that only authorized outgoing requests are allowed from your device.
  2. Server-side Firewall: Protects the server from malicious incoming traffic by allowing only legitimate requests.

4. HTTPS/SSL
SSH using TCP tunneling over HTTP ...

HTTPS (Hypertext Transfer Protocol Secure) ensures that data transmitted between your browser and the server is encrypted using SSL/TLS (Secure Sockets Layer/Transport Layer Security).

  1. SSL Handshake: Establishing a secure connection involves:
    • ClientHello: The browser sends a ClientHello message to the server, initiating the SSL handshake.
    • ServerHello: The server responds with a ServerHello message, providing its SSL certificate.
    • Certificate Verification: The browser verifies the server’s certificate against its trusted Certificate Authorities (CAs).
    • Key Exchange: Both parties generate session keys for encryption.
  2. Secure Connection: Data is encrypted and decrypted using the session keys, ensuring secure communication.

5. Load Balancer
What is a load Balancer and its Types ...

Load Balancers distribute incoming network traffic across multiple servers to ensure no single server becomes overwhelmed, improving availability and reliability.

  1. Traffic Distribution: The load balancer receives the request and decides which server to forward it to based on various algorithms (e.g., round-robin, least connections).
  2. Health Checks: Continuously monitors the health of servers to ensure requests are sent only to healthy servers.

6. Web Server

The Web Server (e.g., Apache, Nginx) handles the incoming request and serves static content (HTML, CSS, JavaScript, images).

  1. Request Handling: Receives the HTTP request from the load balancer.
  2. Static Content: Serves static files directly if the request is for static content.
  3. Forward Request: If dynamic content is needed, forwards the request to the application server.

7. Application Server
Web Server and Its Type - GeeksforGeeks

The Application Server (e.g., Node.js, Django, Ruby on Rails) processes dynamic content, executes business logic, and interacts with the database.

  1. Processing Request: Executes the server-side code to generate dynamic content.
  2. Business Logic: Performs necessary computations, logic, and decision-making based on the request.
  3. Database Interaction: Queries the database for any required data.

8. Database
Database Design Bad Practices | Toptal®

The Database (e.g., MySQL, PostgreSQL, MongoDB) stores and retrieves data as requested by the application server.

  1. Query Execution: The application server sends SQL or NoSQL queries to the database.
  2. Data Retrieval: The database fetches the requested data and sends it back to the application server.
  3. Data Storage: Stores any new or updated data as requested by the application server.

Conclusion

The process that occurs when you type https://www.google.com in your browser and press Enter involves multiple steps and components working together seamlessly. Understanding this workflow not only helps you appreciate the complexity of web interactions but also prepares you for technical interviews and real-world problem-solving in software engineering.

Car Collision Game: My Journey as a Developer

  Car Collision Game: My Journey as a Developer Project: Car Collision Game Developer & Designer: Amira Sayed Mohamed Ali The Road to ...