+ All Categories
Home > Documents > omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design...

omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design...

Date post: 07-Oct-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
19
P4 This is a report on how I designed, tested and improved my game which I made on green foot. The link to the game is: https://www.greenfoot.org/scenarios/23241 In the screen shot below shows the code for the background of my game. “super” is a command for the superclass to be set to the numbers in the brackets. In “my world” it is set to 600 by 600 pixels. So, the background I created in paint will be 600 pixels wide and 600 pixels tall. This is the result from the code above:
Transcript
Page 1: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

P4

This is a report on how I designed, tested and improved my game which I made on green foot. The link to the game is: https://www.greenfoot.org/scenarios/23241

In the screen shot below shows the code for the background of my game. “super” is a command for the superclass to be set to the numbers in the brackets. In “my world” it is set to 600 by 600 pixels. So, the background I created in paint will be 600 pixels wide and 600 pixels tall.

This is the result from the code above:

Page 2: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

Next, I added the code below to added three classes “car” which is the car which the player is going to control. “cactus” which is just in the background which moves while the player is moving. “line” which is the line in the middle of the road as the player moves.

The result of this code:

Page 3: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

The screenshot above shows code which spawns on coming cars using “addObject” which adds the actor and the number determines how many spawns at a time. It also spawns cactus plants for the background which move when you move.

This code makes the cactus in the background move down as the user moves. Get x and y are the location each of them will spawn in.

Page 4: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

This piece of code is declaring the variables key down. This makes sure the car moves in the direction with the arrow key for example pressing left will make it go left. There is also code which displays game over when the car hits the oncoming car which. Add object adds the game over image.

This piece of code is what stops the game when the car hits the other car “car 2”. Greenfoot,stop freezes the game and has to be reset to unfreeze.

Page 5: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

This piece of code is for the sub class “car 2” and this makes the car move in the oncoming direction. “set location” spawns the cars and move down makes it move the opposite direction.

This is the code for the line which is simple, and it makes the line in the middle of the road travel as the car moves. As it reaches the bottom it gets removed so it has a moving effect.

Page 6: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

P3

I will produce a design document below by using narratives, pseudo code, flow charts, action lists, graphical tools and I will also create a story board. This is to show the design before the game is created and how it helped.

Narrative

The game I want to create is a car game which requires the player to avoid any objects such as on-coming traffic by using arrow keys. The aim of the game is to get as far as possible without hitting any objects, so you lose.

Pseudo code

I will use if statements for the direction the car will travelling when each arrow key is pressed. An example is:

If the up arrow key is pressed then car moves upwards direction

If the right arrow key is pressed then car moves right direction

If the left arrow key is pressed then car moves left direction

If the down key is pressed then car moves downwards direction

Flow chart

No Yes

StartGame

Move Car

Touches on-coming car

Game Over

Page 7: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

Action list

Action Effect

User presses up arrow key The car will move upwards

User presses right arrow key The car will move in the right direction

User presses left arrow key The car will move in the left direction

User presses down arrow key The car will travel downwards

Car hits on-coming car Game will stop and have to reset

User clicks reset The world will reset to the beginning

User clicks run the car will start to move and the other vehicles will start to spawn.

Storyboard

M

Avoid any vehicles in your direction Crashed

Game

Over

Game over screen

Page 8: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

M1

These sentences below are the different data types which I will be using to create my car game and why I will be using them.

Program design- using a design can help ease the process of making a game as you follow simple guidelines to make sure that the game works how you intended it to.

Purpose- the purpose of my design is to create a challenging car game where you must avoid cars that are coming towards you.

Modularity- modularity is important for coding any type of software including computer games

Systematic approach- making a computer game requires analysis to make sure the game runs correctly without any issues. Design, testing and evaluation is required when creating a computer game.

Data dictionary- it is descriptions of certain objects which can be seen in a program with the purpose of them.

Data types/ structures- this is how data is stored using Boolean and string for characters.

Methods/procedures- this is instructions which is used by the program to make sure each object does their job correctly.

Parameters passed- this is the information which travels between different parts of the program which makes the program function correctly.

Return values- this is what you get back from the program based on what you have done on it.

Scope- this is what the object does to see where it can access certain data

Visibility- code visibility is where parts of a program can be seen normally private or public.

Public- if a code uses public, other parts of the program can access it.

Private- if a code uses private, it can only be accessed where it has been declared.

Static- static variables are always ran in the program in the background.

Friend- friend functions can access private data within the program

Objects- objects have codes that tell them what to do and how to interact within a program.

Instantiation algorithm design- it is the creation of a real instance realisation of a template for example class of objects or computer process.

Page 9: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

Develop- developing requires designing and visualising

Choice of language eg object oriented or procedural- I chose object oriented for my game as I think object oriented is more suited towards the creation of games. It lets you make sub classes and allows me to reuse code for different classes.

Development facilities- I will use the facilities at my college to create my game on a computer which has greenfoot.

Menus- my game will not contain menus as the game is simple and there is only one mode. Menus are suited to games which have different game modes eg multiplayer and campaign.

Editing techniques- I can edit things which are graphical for example the image of the class I have created.

Saving files- it is important for me to save my files as I go along so if any software issues occur or I accidently close it my work will be safe.

Building or compiling code- this checks the code for any errors made. If there are errors, it should tell you what it is and if there are none the code will run normally.

Built-in help facilities- there is a help section which helps me if I am stuck on anything when making my game.

Good programming practice eg suitable comments- comments will help whoever is looking understand what each code does in my program.

Small unitary code blocks- code blocks has tasks which run by themselves and can also duplicate and delete.

Invocation- this calls a specific function or starting function.

Consistent indentation- indenting codes makes it neater and clearer to understand.

Descriptive identifiers- each variable must have a clear and descriptive name so it avoids any confusion when coding.

Coding: good use of program structures- the program should be neat and organised so that there are no unnecessary codes written.

Syntax rules for the language- i must follow syntax rules for example adding a bracket where its needed or a semi-colon at the end of a line.

Assigning values- assigning values is giving each variable information which they then present.

Operators; input/ output statements- taking in information and giving it in a more understandable way.

Selection methods eg calls to external procedures-

Iteration loops eg pre-conditioned- a precondition is a condition that must be done before trying to run the whole code in a method.

Page 10: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

Post-conditioned- a postcondition is a condition that is true after running the whole code in a method.

Fixed- a fixed loop is instructions which are set to run a specific number of times which is repeated throughout until another condition is met.

Data representation: types eg integers- an integer is a whole number.

Real numbers- real numbers include all numbers.

Booleans- Booleans are statements which consists of true and false.

Characters- these are the values which is inputted from a keyboard. These consist of numbers and letters.

Strings- a collection of characters which is either a phrase or words.

Declaring eg assigning constants- these are variables/places holders which have one fixed value.

Variables- these are parts of code which can be changed repeatedly either private or public.

P5 & M3

This is my report after testing my game after I have created. In this report I will talk about the different tests I did to ensure that my game works correctly. I will also provide screenshots as evidence of this.

Testing methods:

Black box testing- black box testing was done by some of my friends who did not see the code for the game. This helped me more with the graphical aspects of my game and how it can be fixed.

Whitebox testing- Whitebox testing is done by someone who understand the code throughout, so everything can be understood easier than someone who doesn’t know. It can help improvements as they know the code better.

Test Number

Reason for test

Expected result

Actual Result

Possible Fix

Evidence of test

1 To see if the game over screen comes up when you lose

When the car hits the other car, it will say game over

When the car hits the other car the game over screen comes up

Make the game over screen a bit bigger

Page 11: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

2 To see if the car should move side to side, up and down when the arrow keys are pressed

The car will move in the correct direction

It moves when you press the arrow keys

None needed

3 To see if the reset button works in the game

The game should restart to the beginning

The game restarts as new.

None needed

4 To see if the game stops when the user hits another car

The game should freeze and display game over

The game stops where it is

None needed

5 To see if the game can pause and resume mid game

The game should pause and start when pressed

The game pauses

None needed

M4- Game feedback

Page 12: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

I got a few people to play my game, so I could ask them a few questions about what they like, what they don’t and how I can improve the game.

What do you like about my game?

- It’s fun to play- It is challenging- Interesting background objects- Fast pace game you must be quick

What don’t you like about my game?

- There is no score tracker- There is no game over screen at the end- Sometimes the game glitches and freezes- The enemy cars spawn too quickly

What can I improve about my game?

- Add a game over screen at the end- Add some sounds- Add a score system and leader board.

Conclusion

In conclusion the game seems to be good to people however I can add somethings to make it better. the action I took from my feedback was adding a game over screen every time the car crashes. This gives my game more content and lets the player know that they have crashed and lost the game. From this screen they can press restart which will stake them back to the beginning.

Here is a screenshot that shows this below:

Page 13: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

User documentation

Specified game applications: My car game is designed to be used in a supported web browser or the IDE application Green foot which can be downloaded on most operating systems

Purpose of game: The purpose of my game is to simulate driving through on-coming traffic while avoiding anything coming towards the player.

Operation of game: For the player to move they must use the arrow keys to move the car either left, right, up and down. The player then must avoid any on-coming cars so that they don’t lose the game.

Frequently ask questions:

Q- Aim of the game?

A- Avoid any on-coming cars and get as far as possible

Q- What happens if I lose?

A- The game will freeze where you crashed, and you must restart using the reset button in green foot.

Q- How do I play?

A- Use the arrow keys to move the car around the screen and avoid cars

Technical documentation

Data dictionary – A data dictionary stores lists of field names which are used to build the program. A data dictionary used in my car game is shown in table below.

Field name Data type purposeSPEED private This determines the

speed of the car.UP, DOWN, LEFT, RIGHT

private This determines the direction the car will going on depending on the arrow key pressed

Algorithm designs including control methods- A control variable is a variable which has a value that doesn’t change within the code.

Selection-

Iteration- This runs the lines of code as many times as you want.

Page 14: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

User interface method design- I used this as shown above in all the techniques I have shown.

Action charts- action charts show what the game does however I used a flow chart for my game.

Input-process-output tables- Input-process-output tables creates an average by using three numbers and dividing by 3. I did not use this process when making my game.

Class and instance diagrams- these show the connections between classes and the instance variables and class variables to methods.

Data flow diagrams- this is a simple form of showing the aim of your game as shown in my previous task when designing my game. It shows the process of the game.

D2

I will give some examples from my game on how the structure of a game can assist maintenance and capacity for extension. Java programming has a lot of elements which assisted me maintenance of my game and how I can improve the game. Below is some example I used to do this.

Variable names

Having a descriptive variable name makes coding easier as you will remember what it is and it will be easier to remember when coding. This can make locating errors within the code easier as the name is descriptive. The screenshot I provided shows the variables I have used.

Indenting and layout

Indenting my code makes it look much neater and clearing. Having a clear layout makes it more understandable and less messy. If you put random bits of code everywhere it wont look nice and very confusing to someone looking at the code. The screen shot below shows my layout in the code.

Page 15: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

Code comments

Having code comments can help people understand what each piece of code does. They are useful for identifying functions of the code however it does take up a lot of space and does not look tidy. Also not every line of code needs comments as they are self-explanatory. Overall using comments are useful as they help identify and fix bugs within the program. The screenshots below show comments in my code explaining what the bits of code do.

Page 16: omarbensayedhome.files.wordpress.com  · Web view2019. 2. 17. · This is to show the design before the game is created and how it helped. Narrative The game I want to create is

Conclusion

In conclusion I have made improvements to my game using some of the feedback I have received which I believe makes my game better. I added a game over image when the car hits another car which is useful, so the user knows when they have lost. I will add some screenshots of my game below.


Recommended