Opening Title Fire'nIce Team Member: Zhang Yujie Wang Huan Xiao Fei Cheng Peng Tutor: Alexandre...
-
Upload
byron-harmon -
Category
Documents
-
view
217 -
download
0
description
Transcript of Opening Title Fire'nIce Team Member: Zhang Yujie Wang Huan Xiao Fei Cheng Peng Tutor: Alexandre...
Opening Title Fire'nIce Team Member: Zhang Yujie
Wang Huan Xiao Fei Cheng Peng
Tutor: Alexandre Devert
SSE USTC
Team Leader: Wei Qiang
Content
Object
Tools and means
Design
Tasks
Object
In our project, we clone an action-puzzle game named 'Fire And Ice' which was first released in 1992.
At last, we will try to make the final code high-efficiency in memory and CPU time.
Leading role:Dana
Tools and Means
Language: C++ Function Library: SDL(Simple DirectMedia Layer) SDM: Agile Development Development Tool: visual studio 2010 Gimp
Design
The project uses agile development methods. In our weekly work, we complete a certain task and realize the gradual optimization of the code.
So,our initial design for this project is not so perfect.It is just for an easy beginning.Look the picture in the next page:
Design
Task1:
Play the game to the end ,make a printscreen
for each level.So we have more than 100 maps that printed from the game.Using the maps we make an HTML as a guide:
Task2
Task: Showing a picture in the window and move it
with key pressing.
Task2
To Show: Using the function “SDL_BlitSurface”, “put” a
png to the screen. Record the offset of the png: (x, y)
Task2
To Move: Two new parameters: (xVel, yVel) xVel: speed of the motion on horizontal←→ yVel: speed of the motion on vertical ↑↓
Get events from the keyboard: Case: UP: yVel -= some value Case: DOWN: yVel +=some value Case: ….
Task2
Then, change the offset(x, y) according to the speed on vertical and horizontal.following the formula :
x += xVel; y += yVel; Put the image on the new position according to the
new offset(x, y). But, before put a new image on the screen we
should always flush the screen ,otherwise we will see a lot of shadows like this:
Task2
Task3 Part1
Task: Make the mario move, using an image sheet.
How to get a small clip of the sheet? We need three parameters: offset, height and
width. Like this:
Task3 Part1
Task3 Part1
The animation needs a sequence of small clips of the Mario.
We use an array to store the sequence of the clips.
Task3 Part1
We make a new parameter: status. If the keyboard state is UP: Set status = UP, then put the “up clips”
sequence to the screen according to the position we get from the (x, y).
Task3 Part1
Transparency
The result will be
Task3 Part2
Read a text file which looks like that################ ## ### D## ## ###############
Where '#' is a wall, 'D' is a little guy. The program load a picture containing pictures for the little guys and the walls.After this task we can load pictures and show them.
Task3 Part2
We built a new class named Tile, including its position, width, height.
Then we built a new array named tiles. Read the map, case ‘#’, new a Tile, calculate
its position, then put it in the tiles array.
Task3 Part2
Put the tile pictures according to the positions of the tiles.
Task3 Part2
But now, the tiles are only images, Mario can walk across them.
How to solve this problem? We built a function: Collision Detection.
First, we add a property in both Mario and Tiles: SDL_Rect. It’s like a box or a “shell”, like this:
Task3 Part2
When the two boxes get close to each other, one can not cross another’s boundary.
Then , Apply the collision detection function to every tile.
Task4
In task3, there are only one kind of tile: block, and the block has only one status. But in the game, there are many kinds of things: blocks, fire, ice, jar, pipe…as:
Task4
The blocks and the ices also have 4 kinds of status:
none-joined: left-joined: right-joined: Both-joined:
Task4
Because in the map file, every block is the same:
We need to judge every block and ice what kind of status they are.
Task4
Before, we read the map file, store every character into an array like this:
Eg: file: ’####’; in the array: ‘####’ But, in this task, we judge and change the
type of every tile, like this: File:’####’; in the array they are turned into:
‘[##]’
Task4
Case ‘[’: put a onto the map; Case ‘]’: put a onto the map; Case ‘#’:put a onto the map; Case ‘^’: put a onto the map. So, in the map, file ‘####’ will be showed like
this: Not like this:
Task5
Change one most important algorithm in our project:
Collision Detection is replaced by Position Detection!
Reason:Collision detection can not get Dana's next action after the 'collision';But position detection can do different actions after the collision,such as dropping,climing,stopping or dying.
Task5
With position detection, when Dana come to some place, we can know what’s around it. It makes many problems easy to solve.
Such as:
Task5
In this situation, there is a block in front of Dana, and we can know from position that there is no block in the left-up position, or up position. According to the rules, after pressing “left” key, Dana will climb to the top of the block.
Task6
Each of us draw 10 maps for this project.
Like:
Task……
Now we begin to making music and sound effect,but have not finished…
Next term , We will try to make the code more efficient ,reducing the amount of ‘if…else…’ that we use, optimizing the algorithm in detection, in level selecting, etc.
The End
Thanks for Alexandre Devert very much! AND
Merry Christmas! Happy New Year!