Chris Pollett > Old Classes > PIC197 ( Print View ) Enrollment info Course Info:
Homework Assignments: Practice Exams: PIC: |
HW#2 --- last modified January 16 2019 00:35:19..Due date: May 1st 5:30 ========= Files to be submitted: p197hw2file1.zip -- a zip file containing your ====================== project directory and all the files in it. HW1 Purpose: Become more familiar with sprites and data structures in ============ game programming. Specification: ============== For this assignment you need to modify demo 03 out of the book. The goal of this assignment is to write part of a space invaders games. As a first step you should modify Bckgnd.bmp to be some space-like setting. Then modify Sprites.bmp to contain the various kinds of space invader characters in various states of motions. You can also make some bunkers, and the players character. (Be imaginative if you don't like the traditional characters one's.) You should modify LoadImages() in Main.cpp to load in these new images. Then you should add getX, setX, getXVel, setXVel and getY, setY, getYVel setYVel methods to CObject so you can get and fix a CObjects location. You should write a new class CInvaderGroup. It should contain in it an STL vector of Space Invaders (which are just CObjects). Its clear method should clear all the invaders from the vector. Its create method should set up the CObject space invaders in the vector. i.e., set their initial locations and speed and images. You can make this method as general as you want in terms of the parameters you have to supply --for instance maybe pass a struct called CINVADERGRPDESC -- or take no parameters if you feel like this assignment is taking too long. Although all the invaders are in one vector they should appear on arranged in rows and columns on the screen and each row should use a different kind of invader image. The CInvaderGroup's remove(int i) method removes the invader at the ith location of its vector. The size button returns the current number of invaders left in the group. The CInvaderGroup's draw method calls all the draw methods of invaders stored in the group. The CInvaderGroup getTop, getLeft, getRight, getBottom methods should return the coordinates of the Topmost, RightMost, Left-most, Bottom-most invader in the group. The CInvaderGroup's move method call all the move methods of invaders initially it should make invaders move left to right. When they reach the right-most invaders reach the right hand side of the screen all the invaders should move down a bit and start moving right to left. When they reach the left hand side they should switch direction again. When the Bottom-most invaders reach the height of the bunker, the CInvaderGroup should be cleared and recreated. You should then modify Main.cpp's CreateObject function to create and instances of the class CInvaderGroup and initialize it and then also create CBaseSprite's for each of the three bunkers and the players character and say where each of these should be on the screen. Next modify ComposeFrame to move the CInvaderGroup object, then draw out the background, CInvaderGroup object, your character and the bunkers. The keyboard_handler should be modified so that left and right starts your character moving left or right. The space key should cause the size of the the CInvader group object to be checked. Then a random space invader from the CInvaderGroup should be deleted. The up and down keys should stop your character from moving. Point Breakdown for HW2 ======================= Documentation..........................1pt CObject correctly modified.............1pt CInvaderGroup's create method works....1pt CInvaderGroup's draw method works......1pt CInvaderGroup's remove method works....1pt getTop,getBottom,getRight, getLeft work....................1pt CreateObject modified correctly........1pt ComposeFrame correctly modified........1pt keyboard_handler correctly modified....1pt Total.................................10pts |