COMP2611: Computer Organization Fall 2024
Programming Project: Aircraft War
(Deadline 11:55pm, Dec 1, Sunday via Canvas) Copyright: All project related materials (this project description, modified MARS,project skeleton) is for personal usage of students of HKUST COMP2611 Fall2024 offering. Posting it on a website other than the official course webpagconstitute a breach of the copyright of COMP2611 teaching team, CSE andHKUST.
1 Introduction Aircraft War is a simple yet challenging game that has captured the hearts of
millions around the world.In this game, players use a combination of keyboard controls to maneuver theiraircraft and manage weapon systems. Your objective is to control your airplane,shoot bullets at enemies, and avoid being hit by enemy bullets and aircraft.
In this project, you will implement the Aircraft War game using MIPS assemblylanguage.As shown in Fig. 1, the game features a simple yet engaging design. A demovideo is included in the same zip file for your reference. This project is a modifiedand simplified version of the original game, with detailed rules outlined in thefollowing section.The game runs on a modified version of MARS. To get started on your excitingjourney as a game developer, download the Modified MARS and the skeletoncode provided. We will also regularly update an FAQ file on the course website,so be sure to check it frequently for any questions or clarifications.
2 Game Objects and Coordinate System The game window, as illustrated in Fig. 2, is organized as a grid, with the x-axialigned horizontally and the y-axis aligned vertically. The origin (0,0) is located2Fig. 1: GameFig. 2: Coordinate System
at the top left corner of the game window. As you move away from the origin, thex-coordinate increases to the right, while the y-coordinate increases downward.The dimensions of the canvas are 480 pixels in width and 700 pixels in height.Table 1 outlines the various objects that will be utilized in the game. Theseobjects will be rendered within the game window and will each serve differentfunctionalities. Detailed descriptions of these objects will be provided in thefollowing sections.
2.1 Game Control
In the world of Aircraft War, certain physical principles are simulated, we willintroduce them one by one.In the provided video, you can observe how keyboards control your own airplane’smovement.2.2 Background The game features a fixed background that does not require any movement omanipulation. This background is shown in Fig. 3. Players can focus on controlling their aircraft and engaging with the game without needing to adjust thebackground elements.2. GAME OBJECTS AND COORDINATE SYSTEM 3
ImageGame ObjectWidth × Height (pixels)Aircraft War102 × 126Enemy 1Table 1: Game Objects
2.3 Objects
The key part of this project is to implement the logic of the enemy’s bullets andenemies. Collision detection is the core component.The key aspect of this project is implementing the logic for enemy bullets 代写COMP2611: Computer Organization andenemies, with collision detection being the core component. Each object in thegame has a unique ID; if an object is destroyed, its ID is set to -1. In Java, allobjects are stored in a hash map called the game object list, allowing you toaccess each valid object by its ID.4Fig. 3: Pure backgroundTab. 1 has listed all objects used in the game. The entire game frame refreshesevery 30 milliseconds. We maintain a counter, total cnt, to track the number of
30-millisecond intervals that have passed.When total cnt%120 == 0, a small enemy (Enemy 1) is generated. Once thereare two Enemy 1s, they will trigger the creation of a medium boss. Similarly,two medium bosses will lead to the appearance of a big boss. This pattern ofenemy generation continues throughout the game.
2.4 Movement
You are responsible for controlling your own airplane in the game. While thecode for upward movement has already been implemented, you will need toimplement the remaining movements: down, left, and right.Regarding enemy movement, you do not need to worry about the generationand movement of enemies, as that code has already been provided. However,
it is recommended that you review their logic, as understanding how enemiesoperate will help you grasp the overall game mechanics better.2. GAME OBJECTS AND COORDINATE SYSTEM 5
2.5 Bullet Generation
You need to implement the logic for enemy bullet generation. There are threetypes of bullets associated with Enemy 1, Enemy 2, and Enemy 3, as shown inFig. 4.– Enemy 1: This enemy generates one bullet each time, which moves straightdown.– Enemy 2: This enemy generates two bullets, with one bullet moving towardsthe lower left at a 45-degree angle and the other moving towards the lowerright at a 45-degreeangle.– Enemy 3: This enemy generates three bullets: one moving straight down andtwo moving towards the lower left and right at a 45-degree angle.Make sure to implement thesebullet generation patterns according to the specifications for each enemy type.a) Enemy 1(b) Enemy 2c) Enemy 3Fig. 4: Different bullet types2.6 Collision detection You need to implement detection for three types of collisions in the game:– Collision between your airplane and any enemy
– Collision between your bullet and any enemy– Collision between enemy bullets and your airplane6The pseudo code for these collision detection mechanisms is provided in theMIPS file. Make sure to refer to it while implementing the logic for each type ofcollision
2.7 Game Score and Game End In the game, you start with 20 units of health (blood). When you are hit, yourhealth decreases by 1. The health of the enemies is as follows:– Enemy 1: 3 health points (3 bullet hits to destroy it).– Enemy 2: 5 health points (5 bullet hits to destroy it).
– Enemy 3: 10 health points (10 bullet hits to destroy it).When you successfully destroy an enemy, your score increases by the enemy’soriginal health points.It is important to note that if you collide with an enemy, your health will decreaseby the enemy’s original blood. For example, if you have hit Enemy 2 witbulletsthree times, it has 2 bloods left; but then you crash into it, your health willdecrease by 5 (the original blood of Enemy 2), and your score will increase by 5.End Condition:You win the game if you can survive for 60 seconds, which is represented bytotal cnt = 2000, and your blood remains greater than 0.In contrast, if your health drops to 0 or belowat any point within those 60
seconds, you will lose the game immediately.
3 Game Implementation
Implementing Aircraft War in MIPS assembly can be challenging, but you won’thave to start everything from scratch. The modified MARS (copyright: COMP2611teaching team) takes care of the fancy user interface, while the MIPS code priwhich is well-organized with subtasks assigned to different MIPS procedures. Although it is recommended to read the skeleton code and grasp the details, youshould still be able to complete the project by understanding the overall codestructure and focusing on individual tasks assigned to different procedures withwell-defined interfaces.3. GAME IMPLEMENTATION 73.1 Data Structure
Variables
Description
total cntthe total number of 30 millisecondsbullet number the number of 30 milliseconds, every 10 generate a bullet and set it to 0
list of id of self bullets, 100-119enemy listlist of id of enemies, 500-519enemy bullet listlist of id of enemy bullets, 900-999scoretotal scoreleft bloodleft bloodTable 2: DataSegment Variables and DescriptionsAll objectsare surrounded by a rectangle. This table contains four elements youeed to consider during maneuvering any objects.Rectangle attribute Description
xThe x coordinate of the top left corneryThe y coordinate of the top left cornerwidthThe width of the rectangleheightThe height of the rectangleTable 3: Data Structure of a Rectangle All data variables used in the gameare declared as static and are defined atthe beginning of the skeleton code. Tab. 2 provides a comprehensive list of allvariables utilized in the game. Some of the variables listed in Tab. 2 are complex, meaning they are not represented by a single value but instead consist ofmultiple sub-variables also known as member variables or attributes). Thesecomplex variables bear resemblance to the concept of structs in the C programming language.It’sunderstandable if the extensive list of variables described here feels overwhelming, and some of them may not make sense to you at this moment.However, once you begin working on the project skeleton and actively engage inimplementing the tasks, these variables will become much more comprehensible and meaningful toyou. Don’t worry, as you delve into the project and gainands-on experience, their purpose and relevance will become clearer.ou can also add more content in data segment. Ifyou have any new ideas, youan post them in piazza. More information is shown in the code.83.2 Game Loop The main game loop operates as follows:
- m loop:This is the main loop where all the game logic will be executed.
- Initialization: Bofore entering m loop, the skeleton has already initializedsome components.
- Get Time Retrieve the current time and store it in register $s6. You canignore the details of how this is done.
- Game Over Check: Judge whether the game is over or not. This is thefirst task you should finish.
Keyboard Input and Movement: Capture keyboard input to controlyour airplane. Implement the movement for down, left, and right as yoursecond task.Bullet Management: Generate your own bullets; move bullets; Destrobullets if they collide with other objects or move off-screen. These functionshave already been implemented.Enemy Management: Create enemies; move enemies, and Destroy enemies if they move outside the screen. These functions have already beenimplemented.
- Enemy Bullet Generation: This is the third task. Enemy 1 generates onebullet. Enemy 2 generates two bullets, which just reuses same codes twicewith a different argument. Enemy 3 generates three bullets, reusing the samecodes three times with a different argument. Note that when you want tocreate more bullets, youonly need to copy and paste the code you use ingeneration one bullet. It isquite straight forward, six types of bullets actuallyfollow the same logic.
- Enemy Bullet Movement: Move enemy bullets and destroy them if thego off-screen.
- Collision Detection (Airplane vs. Enemies): This is your fourth task.Implement basic collision detection functions to check if your airplane collideswith any enemies. Loop through each legal enemy in the enemy list.
- Collision Detection (Airplane vs. Enemy Bullets): This is your fifthtask. Use basic collision detection functions to check if your airplane is hitby any enemy bullets. Loop through each legal bullet in the enemy bulletlist.
- Collision Detection (Your Bullets vs. Enemies): This is your sixthtask. Implement basic collision detection functions to check if your bulletshit any enemies. This will require nested loop: first, check each bullet in yourbullet list, and then for each bullet, check if it hits any enemy in the enemylist. Here is a double loop, you need to implement a loop for enemy searchwithin the outer bullet loop.
- Screen Refresh: Refresh the screen to update the game state. You do notneed to understand the implementation details of this step.
- Repeat: The loop returns to step 1, repeating the game loop.4. TASKS 9
4 Tasks Read the skeleton code carefully. Do not trap yourself in understanding everysingle line of the code.Top Priorities:
- Understand the data structures used in the skeleton;
- Trace the game loop, understand how it works;
- Figure out the functionality of each procedure.
Once you build up a big picture of the project, zoom in to the programmintasks, and examine the comments and example codes carefullyCaution: It is important to note that you should refrain from modifying the skeleton code directly. Instead, you should add your own code within the designatedprocedures while adhering to the structure and organization of the existing code.This approach ensures that you can integrate your implementation seamlesslywithout disrupting the functionality of the skeleton code.
Task 1-6: Coding Tasks
Tab. 4 outlines all the programming tasks you need to implement, with each taskcorresponding to a specific procedure. Each of these procedures, except for Task1, does not require any input or output parameters. You may find it convenient tocall other procedures within these tasks to streamline your implementation. It isessential to carefully read the step-by-step instructions provided in the skeletocode for each task, as the descriptions in this document are brief. Ensure thatyour implementation adheres strictly to the instructions outlined in the project
skeleton, without overlooking any operations on the required variables, and avoidperforming any actions outside of what is specified. Additionally, remember topreserve any s registers used within any procedure by saving them onto thestack, as this is crucial for maintaining the integrity of your program’s stateacross procedure calls.Try to follow MIPS conventions and good programming practices,e.g.,commentour code properly and use registers wisely.1
标签:enemy,COMP2611,will,game,Computer,bullets,Enemy,Organization,your From: https://www.cnblogs.com/CSE231/p/18567554