Friday, 24 February 2012

Week 2

In week two our group got together and we tried to put the moving background into the code that i had already written. It was hard to incorporate it into the classes that i had made. We tried it all week but we just couldn't get it to gel. Finally after many YouTube tutorials and sample code online i came up with it. We have a scrolling background and a chopper that moves and shots. The last thing i did this week is that i incorporated an enemy into the game. It an attack helicopter that automatically moves left and shots.

In the next couple of days im going to try and incorporate random spawning enemies that will make the game more difficult. Then it will be onto collision detection.

Also i thought i put in a screen shot for week one. I don't know where it has gone. I'll upload my week two one now. But it wont show the scrolling background. Again the background and sprites are all temporary ones that we are just using for the moment. 


Friday, 17 February 2012

Week 1

This is my blog for my assignment for OOP which is going to be a group assignment. At the end of each week i will post on my blog and explain all the stuff i have done to the assignment. Over Christmas i did some study on XNA gaming which helped me a lot. For starters we got together in our team and did a rough sketch of what we wanted the game to look like and what we wanted it to do. After this we divided some of the roles out to members of the group to go away and study and learn about. For graphics we assigned Niall to it. So he would be doing all the sprites for the game. For music we put Craig on this seeing he has a music background. He would be doing all the noises and music our game would be making. We assigned the moving background for Les to look up. Then Matthew and myself did the rest of the stuff between us for know. Just so we all get a bit to study at the start. There was collision, getting the sprites to move, making them shot, and the text left to do for starters. There will be a lot more to do later on. I started with getting a temporary sprite, background and foreground just to get the coding started. I made a few classes for my objects. I would have a class called GameEntity that would hold all my variables that would be common between all the class i can use. Then i have classes called chopper, background, foreground, bullet and turret. Each of these classes will inherate all the variables from GameEntity. Doing it this way just makes all the code look so much nicer and easier for external people to understand your code, while also makes it easier to code. In the game entity class i have the variables Sprite which will hold all the sprites for the game, the position, position2, which will hold the positions of the chopper and the bullet. The look and rotation, which works out the direction o the sprite is moving and the rotation. The last variable is isAlive, which if true will keep the sprite alive and if false will make the sprite disapear. The Chopper class in loadcontent() i initialized the starting positions of the chopper and the bullet by there x and y coordinates. I initialize the isAlive to true and the look vector to 0 and -1. I then load all the sounds and sprites into the class. Then i move down to update(), where i initialize the speed of the chopper and install the keyboard and gamepad for the buttons. In here i make the chopper move with the arrows on the keyboard, make the chopper shot a bullet with the space bar and stop the chopper from moving outside of the screen. Also when the chopper hits the ground his isAlive is set to false so he disapears and dies. I dont have the most extravagant collision detection here but this is good for the start. I just have that when the chopper gets to a certain y axis his isAlive is set to false. Then at the end i draw the sprites. The bullet class is pretty much the same where i load the bullet sprite into the class, set the speed of the bullet and make the bullet disapear when it exits the screen. Again with the background and foreground classes i load the images into the classes and draw them at the end. In the main class where all the action happens i add the objects onto the scene. I then draw all the sprites to the scene. Here is a screen shot of my work so far, take into account that all the images are just provisional and will be changed for the proper ones when they are complete.  The chopper is not transparent because i drew it in paint.