Development III of new version of “Time Pilot”: Last Space Hero

Now the development of “Last Space Hero” has been successfully achieved and here is the summary of our rapid prototype.

9-1

 

The main focus of the second prototype is all about a real valuable prototype that is time-saving, simple and easy to figure out whether the core element has fun. Before this project, our professor mentioned several useful points that we should keep in mind. These include:

1. Playable Prototype

It must can be played so that developers could make the test to it.

2.White-box Prototype

3. Vertical Slice Prototype

It is like a movie scene that is useful for pitch and time-consuming.

And a prototype should be done within 7 days and by one person. Remember more time do not ensure good quality and more resource do not make a good product. And in detailed, there principles are important:

1. Before beginning:Rapid is a state of mind.

Make the game simple enough to make sure there is enough time to adjust. Just like write down a paragraph first and then expand it into the whole article. And do make the development in parallel way.

2. Desgin: Creativity and the Myth of Brainstorming

Formal brainstorming has a 0% success rate. Gather concept art and music to create an emotional target. And simulate in your head, which is called pre-prototype the prototype.

3. Development

Nobody knows how you made it and nobody cares. So build the toy first, and if you get away with it, fake it. Remember you cannot polish a turd. And overall aesthetic matters! Apply a healthy spread of art, sound and music. One more time, nobody cares about your engineering.

4. Central Gameplay

Complexity is not necessary for fun. And experimental does not mean complex. And build toward a well defined goal and make it juicy.

And in this project, from the beginning, we are truly in the parallel development. And every function is made separately and at last we combined them together.  The early development we concentrated on the core element of “Time Pilot”, and we overlooked the detailed design of the game unless the main function could work well. And we utilized the concept of  “vertigo” game type to create the emotional experience for the player. It is achieved simply by the high speed of the spaceship. And later this design has been proved to be excellent since  testers noticed the difficulty created by the high speed  and they were driven crazy.  As for the whole game, we tried to make it as simple as possible and there are only several elements included in our game, which are spaceship, enemy, obstacle and boss. However, we used these elements to create strategy and new mechanism for the players. And the rules are easy to understand but hard to obey. So players could learn this game shortly but take time to win it.

When it goes to the problem we have in this project, we have discussed it at the end of the project.

照片 (1)

First, we took too much time at the beginning just to think about the new element that should be added in the game. And then we decided to develop the game first and test the new function one by one. If it is good, expand and explore it. Or we discard it.

Second, after the midterm check, we tended to be conservative because our game was praised highly. We once thought changing  “Time Pilot” into a traditional Japanese RPG game. But then we gave up this idea as we all agreed it was too risky. As Roger said, at last, our game is great for the assignment standard, but there should be more elements that are created by us. These are the elements that we absolutely love.

Third, as this is the first time I used Flash to make the game. I tended to use it from the beginning and built the whole game, meaning I had no idea of using some new tools to make the development easier and better. Learning to take advantage of new tool is the ability that I should acquire in the future study.

However, I have to say our game “Last Space Hero”  is great and we root our passion in this game. We would like to call our game “son” in private time. The advice from Roger is certainly helpful for us and we understand his wish for our future development. Create a own game we like, and this is most important!

Here is the link of our game video:

http://www.youtube.com/watch?v=O3Nm725200E&feature=youtu.be

 

 

The Birth of Play

In this article, I will talk about one question that Huizinga has not offered a detailed explanation. And this question is how the play came to the world.

In my point of view, I think the origin of play is from the creatures’ impulse of exploring untouched object and getting the experience of this world. First the creature gets the bio-signal. After processing, information has been formed in creature’s brain. In this way, the brain produces coerce feeling for creature to understand the world. All the feelings and experience are built based on the bio-signals. The feeling is more like a tension between creature’s body and environment. I call the optical world that creature recognizes as ordinary world.

Here comes the question: how could a creature know something that it has never touched? For creature, what is real comes from the experience and feeling. And when a creature builds a temporary world within the ordinary world, it has the access to another experience. And this temporary world comes from the creature’s imagination. The whole process of having experience in temporary world is the play. At the beginning mostly it serves for survival. For example, a dog running with an invisible partner and pretends the predator is chasing it. And in psychology aspect, creature is able to get positive feedback by playing as it could help it to overcome the fear to the unknown real world by immersing itself into temporary world and have the experience. From the view of the biology, the creature’s brain produces dopamine that causes the feeling of happiness. Therefore, a tendency of playing is carried out.

All the analysis above is merely about the basic play. For advanced play, I would like to use two concepts from the book the Decline of the West of Oswald Spengler to make an explanation about the evolution of the basic play. In this book, Spengler mentioned two concepts Vernunft and Verstand, meaning reason and mind in English [2].

And both of them refer to the basic play and advanced play. For basic play, all it serves based on the need of survival and the temporary world is close to the real world. When it comes to the advanced level, the temporary world becomes abstract. In such play, creature (here I mean human) is chasing goal with no practical meaning and several events have been invented which are related to play, like drama and contest. All of such events share a common feature that they all contain abstract concepts. For example, the contest contains the concept of victory and virtue. But we can still find the shadow of the basic play in them. For instance, when talking about the ancient Greek drama, one characteristic that should be addressed is the drama tended to evoke the empathy of audience. It tried to make audience believe the play was real action rather than a pretended show [3]. There was still strong connection between the real world and the temporary world. In sum, let me put this into a table:

6EFD48F2-DC89-44E0-9821-314CF06C4FCB

Reference

[1] Spengler Oswald. The decline of the West. Oxford University Press, 1991.
[2] Friedrich Nietzsche. The birth of tragedy. Dover Publications, Inc. New York, 1995

Development II of new version of “Time Pilot”

This week we have totally improved the development of “Time Pilot”. To increase the tension between players and game, we increase the speed of spaceship that players control. And also the strategy of adding obstacles in the game seems to work very well, and what we like to see is players getting so nervous when playing this game that even they lose control at last. And for me, two works are very important for me to finish, which one is the function of avoiding obstacles and the other is the flocking behaviors.

Let first talk about the avoiding obstacles:

The obstacles is in fact the cover for the players. The missile could not get through the obstacles, neither the enemies nor the players. And the enemies have to bypass obstacles to keep chasing players. And here is my algorithm:

EnemyMove;

if (hitObstacle is true); then

1. if hit horizontal line of obstacle

then

i. if the players is on its left side;  move left

ii. if the player is on its right side;  move right

2. if hit vertical line of obstacle

then

i. if the player is above it; then move up

ii. if the player is below it; then move down

For example, if an enemy hits the horizontal line of obstacle, it would detect the location of the player and then make the relative movement. Like the following pictures shows:

7-3  This is just a simple algorithm for the avoiding obstacles for the enemies. As our spaceship is always moving ( you can press control button to accelerate), it could not present the situation that the enemies stop moving because the spaceship stops.

And for the blocking behaviors, let me explain it first.In the natural world, organisms exhibit certain behaviors when traveling in groups. This phenomenon, also known as flocking, occurs at both microscopic scales (bacteria) and macroscopic scales (fish). Using computers, these patterns can be simulated by creating simple rules and combining them.

I would use this concept of solve one problem in the game. For the enemies chasing players, I originally just made the enemies follow the location of the players and one thing could happen at last, which is that all enemies would gather together in one place. Just like this:

 

7-2This is not natural game playing experience, so I use blocking behaviors to work out the solution.

And adding separation is what I aim at. Separation is the behavior that causes an agent to steer away from all of its neighbors. And the algorithm of it is:

  1. var v:Point = new Point();
  2. var neighborCount = 0;
  3. for each (var agent:Agent in agentArray)
  4. {
  5.     if (agent != myAgent)
  6.     {
  7.         if (myAgent.distanceFrom(agent) < 300)
  8.         {
  9.            v.x += agent.x – myAgent.x;
  10.            v.y += agent.y – myAgent.y
  11.            neighborCount++;
  12.         }
  13.     }
  14.  }
  15. if (neighborCount == 0)
  16.     return v;
  17. v.x *= -1;
  18. v.y *= -1;

And here is my code:

  1. var count = 0;
  2.  var cha_x =  (_root.ship._x – _x)/40;
  3.  var cha_y = (_root.ship._y – _y) /50;
  4.  for( var i in _root.ship.enemies)
  5.   {
  6.                    if ((this._x != _root.ship.enemies[i]._x) && (this._y != _root.ship.enemies[i]._y))
  7.                  {
  8.                        if( Math.sqrt((_root.ship.enemies[i]._x – _x) * (_root.ship.enemies[i]._x – _x) + (_root.ship.enemies[i]._y – _y) * (_root.ship.enemies[i]._y – _y))< 50)
  9.                         {
  10.                               cha_x += (_root.ship.enemies[i]._x – _x)/40
  11.                               cha_y += (_root.ship.enemies[i]._y – _y)/50
  12.                                count++;
  13.                          }
  14.                   }
  15.         }
  16.  if (count == 0)
  17.  {
  18.        _x += cha_x + (Math.random())*2;
  19.         _y += cha_y + (Math.random())*2;
  20.  }
  21.  else
  22.  {
  23.        cha_x *= -1;
  24.        cha_y *= -1;
  25.         _x += cha_x + (Math.random())*2;
  26.         _y += cha_y + (Math.random())*2;
  27.   }

And now it looks like this:

7-1

 

And finally, let me show the boss to you and good night everyone!

7-4

 

Development I of new version of “Time Pilot”

The second project I have is construct a rapid prototype of a new version of classical 70’s and 80’s arcade game. And our team picked the game “Time Pilot”. “Time Pilot” is a multi-directional scrolling shooter and free-roaming aerial combat arcade game designed by Yoshiki Okamoto, released by Konami in 1982, and distributed in the United States by Centuri.

6-4

From the beginning, I noticed the difference in this game comparing to other air fight game. First, in this game, the shooter is multi-directional rather than being fixed direction like 1942 and Space Invader. And the shooter in fact is fixed on the center of the viewport, meaning the moving object is the background. Therefore the design of this game could be a little different from other air fight games.

One core element of this game is that to use available space to avoid hitting enemies and adjust the direction to attack them. This is why the shooter is designed as multi-directional, the same goes to the enemies. The tension between players ans game is created by the action of avoiding and shooting, which reproduces the real war combat of the aircraft  in my point of view.

And the first week task includes reproducing the camera view, enemies attack, multi-directional movement and shooting. And what we also want to add are the limitation of the map, the new style weapon and the obstacles on the map.

For the most recognizable element, which is the camera view and multi-directional movement, I achieved them in the following way:

  1. function onEnterFrame()
  2. {
  3.     if( Key.isDown(Key.RIGHT) && Key.isDown(Key.UP ))
  4.     {
  5.         dir = 1;
  6.         this._rotation = -45;
  7.      }
  8.      else if( Key.isDown(Key.LEFT)&& Key.isDown(Key.UP ) )
  9.     {
  10.       dir = 2;
  11.       this._rotation = -135;
  12.      }
  13.    ……..
  14.   ………
  15.       else if( Key.isDown(Key.UP) )
  16.      {
  17.         dir = 7;
  18.         this._rotation = -90;
  19.       }
  20.       else if( Key.isDown(Key.DOWN) )
  21.      {
  22.          dir = 8;
  23.          this._rotation = 90;
  24.       }
  25. }

There are 8 situations the shooters would act for the direction. And for each direction ,the background would react relatively, and the codes are like this:

  1. function onEnterFrame()
  2. {
  3.     if(_root.ship.die == false)
  4.     {
  5.             switch ( _root.ship.dir)
  6.            {
  7.                case 0:
  8.               {
  9.                  _x = _x – 2;
  10.                   break;
  11.               }
  12.              // up right
  13.              case 1:
  14.             {
  15.                 _x = _x – 3;
  16.               _y = _y + 5;
  17.               break;
  18.              }
  19.            // left up
  20.             case 2:
  21.            {
  22.               _x = _x + 3;
  23.               _y = _y + 5;
  24.               break;
  25.           }
  26.           //left down
  27.            case 3:
  28.           {
  29.              _x = _x + 3;
  30.              _y = _y – 5;
  31.              break;
  32.            }
  33. ……
  34. …….
  35.           //down
  36.          case 8:
  37.          {
  38.              _y = _y – 5;
  39.              break;
  40.           }
  41. }

So the effect would like this:

6-3

6-1

 

And also I add the function of shooting and explosion when shooter hits enemies and obstacles. The same goes to the situation that the enemies are hit by the missile from the shooter.

6-2

6-5

 

 

The last function I add is the new weapon, and this is just for prototype test of our team on Monday. I try to construct some functions I like and let the team members to find whether it is cool.

By the way, the art works you see are from website. I believe our artist could do a better job. And thanks to Huali, who provides flash teaching resources for me so that I could do all of these in two days. Before this project, I did not touch the flash and now I have got the basic concept of flash 2.0. And I know flash 3.0 could be better, but it takes more time for me to use, considering the purpose of rapid prototype is the speed. So I chose flash 2.0 to develop our prototype.

And still, keep working!

This is our game – Cavalcade

Finally, this is the end and our team has made a successful prototype of Cavalcade. Through four weeks development, I have experienced the process of turning an idea to real, meaning a lot to me.

As for me, the last week I have added the function of the last power-up button and changes the pictures of all stuffs in the game. Thanks to Rachel, she created the art resources for the game within a short time, and the works are really great! Here is the final version of our game:

a5-1 a5-2

I know some of you would miss Mario, but he has done the job for the test. And with his help, our parade float could get to the right position and give audience a best show.

And after enjoying the joy and happiness, it is necessary for me to review this rapid prototype development and figure out what is good and what should be improved. Let me show the picture of our team’s postmortem:

照片

 

And I will talk about it in two sections, one is about the team and another is the improvement for myself and our team.

First, as for our team, we have faced a lot of troubles. Like the failure of the smooth unity moving on the third week, and the presentation cohesion on the fourth week. And we had a quick fixed for our game and a fast adjustment of our presentation. Within the limited time, we have try our best to make full use of it. If one problem occurs, we will figure out whether the problem could be fixed quickly so that it would not affects the whole process of the development. If we could not fix that, there are two solutions to choose. One is use an alternative method to fix it, like when the unity could not move smoothly, I reset the coordination of the unities, which makes them move more fluent and also put them into a happy status (they move step by step, just like doing Hopscotch). And the other solution is making a change of our schedule. But it is dangerous to that, considering the available time is only four weeks. So most of time, we will try to find an alternative method.  And what is more, our team is very sweet. Because there are two Chinese people in our team (me and Jinzhi Zhang), sometimes we were confused about the topic discussed by the team. And our team members would slow down the speed and speak clearly in order to make it easy to understand. They have never considered it as a burden. Also, our team have a slogan for cheering. And Casey picked a Chinese slogan which is from my hometown, which is really warm and cheerful. And our team is good at supporting each other. For example, when I have the problem with the programming, Tina, though she is not the engineer, would voluntarily find some useful resource for me.  In a word, our team is best!

As for me, I had a hard and also wonderful experience in this prototype. This program is such a force on me, leading a quick learning of MOAI and lua. I used about one week to get familiar with MOAI and lua, and used the rest of weeks to develop the game. However, some problems still happened. This is the first time I develop a game, and what I lack is the experience and some basic concept of game programming. On the first week, I particularly focused on the concept of game loop, which is very important for a game programming. But when developing the game, I still lacked a clear understanding of it and did not used it well. The problem came from the method I used for developing the game. I started to program the game by adding the first function of the prototype, which is to ensure the unities could move in the right track. Then, basing on that function, I explore more functions of the game. To admit it, at first, it was fast and easy, as functions I added were not so complex. But when the game got the final development, some problems happened because of the structure of the code file. This is what I tried to avoid at the beginning, but it still happened. And it could be solved if I used the game loop in the right way. I think it is caused by the lack of experience and also the ability of using other resources for help or advice. And also I did not have enough communication with another engineer during the development, most of time I fixed the problem by myself, which is less effective.  But the good thing is that I have learned a lesson and got the treasure for my future from these problems.

And one more improvement I would like to discuss is the alternative model of the prototype at the early development. I found there was a gap between threes tracks members. In detailed, producer would use text and words to express the idea, programmers would think from the view of code, and the artist would think by using images. Therefore, we could not say each team members absolutely understand the idea of the game after a meeting because of the gap. Thus, I think we should find a new way of discussing the game totally together. And tuning the prototype into a card game which the whole group could play would be great solution to this problem. In this way, the whole team could share the information by playing a game. As we know, game is am experience-based activity, I am sure this could fill the gap to some extent. And what’s more, the team could figure out whether the  game is really interesting and we do not have to wait for the result of the programming. The team could find some problems early  by doing an alternative game, which could contribute to the next development.

And last, I want to say thank you to Christina Kalinger, Casey Deans, Rachel Leiker and Jinzhi Zhang. All of you are the best, and it is such a nice thing that we five people share a wonderful four weeks during our life time:-)

20130917_085310 (1)

 

 

 

The Development II of Our Game:Parade

It has been one week since the last update, and I have really added some new functions. This prototype maybe small and simple, but I think this could absolutely show the idea of our team and people are able to get understand of the design.

For this time, I will show the function of happiness bar movement and the power-up buttons.And about the collision function that I mentioned last time, I would talk about its update.

1. Collision Update

Last time the original collision was that Mario stopped when got stuck. During this week, I added the collision event which shows the specific meanings (tire broken and burst fire hydrant). So when the function of collision detected there is a crash accident, it will shows the accident icon and you can hear the sound of that. I will show this with following pictures first:

tire-broken

2. Happiness Bar

This is very important for this game. Because each game has its obstacles. These two obstacles above I talked about will not be a real problem for the player if we could not use them to prevent players from winning. Just to address it again, this game is about parade. The troubles along the way are not big deal for parade itself, but when coming to the audience, it turns to be a disaster. We have designed a happiness bar to record the audience reaction to the parade. And when some random events happen, the audience would get unhappy. If the happy point falls to the end, the game is over.

For this design, I made a function for happiness bar movement. When the crash event happens, the collision detection will send a signal to the happiness function and then the happiness point will fall down a little. Just like:

  • function b_move()
  • print(“j”)
  • print(j)
  • local x2 = stepstick[j +1]
  • local y2 = -655
  • local b_x = stepstick[j +2]
  • local b_y = -655
  • level_hit.level_hit2()
  • level_hit.level_hit()
  • MOAIThread.blockOnAction(level_initiate.prop14:seekLoc(b_x,b_y,level_begin.distance(b_x,b_y,x2,y2)/100,MOAIEaseType.LINEAR))
  • j = j + 1
  • end

And the effect looks like this:

happy bar unhappy bar

3. Power-Up button

Up to now, I added two power-up buttons. And there will be three at last. The first button is the repair button, which could solve the tire broken trouble but would not get the happiness point higher. And the second button is for cheering up the audience to get higher happiness point with the firework. You will find these when click these two buttons:

repair

 

As for the third power-up button, I would add the candy button, which is similar to the firework button getting the audience happy and crazy (especially for the children).

So this is what I have done so far, and I really want to say thanks to our  team members. They gave me courage and also provided me with useful information about the MOAI. Thank you! And keep working!

Why the game Remember Me could not be remembered?

Remember Me is the new game releasing on June 4th 2013, developed by Capcom company. With diversity of games appearing today, Remember Me has successfully attracted the public attention for its romantic art style and the Dystopian world setting.  This story is happens in Neo-Paris, 2084:

Personal memories can now be digitized, bought, sold and traded. The last remnants of privacy and intimacy have been swept away in what appears to be a logical progression of the explosive growth of social networks at the beginning of the 21st century. The citizens themselves have accepted this surveillance society in exchange for the comfort only smart technology can provide. This memory economy gives immense power over society to just a handful of people.

A visionary 3rd person action adventure, Remember Me puts players into the role of Nilin, a former elite memory hunter with the ability to break into people’s minds and steal or even alter their memories. The authorities, fearful of her knowledge and capabilities have arrested Nilin and wiped her memory clean. After her escape from prison, Nilin sets out on a mission to recover her identity, helped by her last and only friend. This search for her past leads to her being hunted by the very people that created this surveillance society.

As well-known to all game designers, a game world could be successful if players are really emerge in it. And for Remember Me, we could have a quick look of its own world:

remember me

remember me 2

So is your mouth still opening:-) And now I will talk about the game in four elements to show the weak point of this game.

1. Anesthetic

I would like to say, this game uses such a postmodern concept to turn the Paris into a city that posts the contrast of glamorous clamor and cold dark silence, remaining the classical romantic Paris style at the same time. The whole world is totally a cyberpunk world. And players could easily lost themselves into this world. So far, this game is great, as the anesthetic element has certainly attracted people’s eyes.

2. Story

And the story shows the deep think of human nature and the fear of the future. It is clear this is not a common topic for the players, but just like the Matrix, once it raises players’ interest, crazy fans would be born and turns into a steady circle of this game.  As for me, cyberpunk style always gets me. I remembered I joined science fiction competition in the meddle school in consecutive two years, and all my works were about the cyberpunk topic.

3. Mechanics

So now I enjoy the art design of this game and cannot wait to enter this world, and then what I have found?  Through the whole process of playing, there are only four memory alter, which makes the identity of the main character Nilin less expressive. It would be a problem if the players could not figure out who they are in the game. The reason is that the failure of self-recognize could handicap the experience into the game world, wasting the hard work of the aesthetic element and the world setting. Also, the tip system for climbing and jumping absolutely destroys the players’ interest of exploring the game. The things goes just like: you know there are countless surprises waiting for you but then you find surprises themselves would say hello to you. As the consequence of this, bad experience has been produced, as the players could not get their own right to analyze and discover such awesome world. This problem does not come from the game theme or the game world itself; rather it comes from the rule and the mechanics which limits player’s freedom. Or we could say this game has not match the players’ need and it provides less than it looks.

In a word, why I criticize this game is that I expect too much for this game, for its theme, the image, the world, the atmosphere of the future Paris and the eternal topic.  But with tip system, I could not feel the fear that the Dystopian world should bring. And the combat system lacks the powerful beat. When finishing this game, memory hunter is still a word for the players, not a real person. We should remember, great idea would come; only we have the ability to express it.

 

 

 

The Development I of Our Game:Parade

So far we have developed our game for over a week, it is such a nice experience as we saw the idea was born and then put it into detailed design. And through one-week MOAI learning, I could say now some functions of the game have been came out. Now I will talk about the game we are designing and what I have learnt about MOAI.

1. The world,the view and the screen

For the beginner, it is easy to get confused by these three concepts: world resolution,view resolution and screen resolution, especially the writing in the book Developing Mobile Games with Moai SDK could a little bit confusing as the author used the world_resolution for representing View Resolution.  It is important to figure out these three concepts,  particularly when the game is 3D type. I will use a picture to explain these, here is the picture:

a2-1

World Resolution is for the game world, you can say there is no boundary if you want, but technologically it’s the resolution of the game background map. And the View Resolution is for view that captures this world, we could compare it as a camera. And the third one is Screen Resolution, it is the resolution for the device showing this game (computer,TV,mobile phone etc.) So remember the coordinate we calculate is based on the World Resolution, not the Screen Resolution nor the View Resolution. Let me use another picture to address this:

a2-2

The camera ( View) captures the view of the game world ( World Resolution) and transmits it to TV ( Screen Resolution). Even the screen is what you see in the end, but this is not real. Remember we are building this world, so focus on the game world!

In our project, the code is like this:

  1. VIEW_RESOLUTION_X = 2048
  2. VIEW_RESOLUTION_Y = 1536
  3. SCREEN_RESOLUTION_X = VIEW_RESOLUTION_X/2
  4. SCREEN_RESOLUTION_Y = VIEW_RESOLUTION_Y/2
  5. — opint the main screen
  6. MOAISim.openWindow(“Parade”,SCREEN_RESOLUTION_X,SCREEN_RESOLUTION_Y)
  7. –setup viewport
  8. viewport = MOAIViewport.new()
  9. viewport:setSize(SCREEN_RESOLUTION_X,SCREEN_RESOLUTION_Y)
  10. viewport:setScale(VIEW_RESOLUTION_X,VIEW_RESOLUTION_Y)

And the game window is like this:

a2-4

2. Now let’s move and hit

One of the functions we have to achieve is to make the object move and collision could be detected when happening. First I will make sure the objects (the parade) move on the right track of the map. Then I will add the function of detecting the collision.

For a simple implementation, I calculated the turning point of the map and used the function seekLoc to ensure the parade is on the correct path.

for  function seekLoc ( MOAITransform self, number xGoal, number yGoal, number zGoal, number length [, number mode ] ), the coordinate of the turning point x and y is the xGoal and yGoalnumber length is the time length of moving. I used the function of  distance(x,y,x1,y1)/velocity to keep the object in steady speed. And these coordinates of turning points are stored in the table step{}. Here is part of the code:

  1.  local step = { -580,700,-580,350,-580,50,540,50,580,50,580,20,580,-550,1000,-550}
  2. while not click do
  3. print(“x”)
  4. if MOAIInputMgr.device.mouseLeft:down () then
  5. while(i<8 ) do
  6. x1 = step[(i-1)*2+1]
  7. y1 = step[(i-1)*2+2]
  8. x = step[i*2+1]
  9. y = step[i*2+2]
  10. MOAIThread.blockOnAction(level_initiate.prop6:seekLoc(x,y,distance(x,y,x1,y1)/200,MOAIEaseType.LINEAR))
  11. i = i+1

It is obvious that each moving section is fixed by two points, which is the start point and the end point.  So when the game begins and there is a click action, the super Mario icon ( I just used this for test. Our object picture would be much better) will move. This is the screenshot of this:

a2-5

And I place two obstacles for hit testing as we can see in this picture. When the program detects the collision, Mario will stop for a while and then moving. This is achieved mainly by this function:

  1. function checkhit(x,y,prop)
  2. local x1 = x
  3. local y1 = y
  4. local x2,y2 = prop:getLoc()
  5. return level_choose.distance(x1,y1,x2,y2) <= 50
  6. end

And if Mario and the obstacle is really close within 50 pixels, then bing! Mario gets hurt and stops for a while. The detailed mechanism of this function I will talk about later, which is related to thread handle. And I would like to show how Mario gets stop by pictures:

level-hit

I know the effect is not good but Mario really gets stuck by this obstacle. And he will stops for about 3 seconds and then keeps moving.

a2-6

 

 

So this is so far I have done, keep working!

 

Three smooth drawing algorithms in game programming

These days I was reading about articles focusing on game loop, and I found that the writer had mentioned three algorithms for smooth drawing. Unfortunately, he did not get them in detailed. And now I will explain them one by one.

Before we  begin, I will introduce the related knowledge. So why we need a smooth drawing algorithm? First we look at the process of game playing:

While(is_playing){

Handle_Input(i_events);

Handle_Update(elapsed_time);

Handle_Draw(o_graphics);

We will set the interval time between two updates. And each time when the game status has been updated, the graphics will be drawn. But there might be a problem: what if the update process has not finished? I mean like when the normal interval time for updates should be 30 frames, but because of something else, this time it takes 60 frames, meaning that when the graphics should be drawn after 30 frames, there is no update! From the view of the player, the object stops for a while and then jumps to a further place. This is an awful game playing experience.

 

Therefore, we need smooth drawing to avoid such problem. And here is the first one:

1. Last-Position & Position Drawing

interpolation

 

drawPosition = (Position – lastPostion) * Statue.interpolate + lastPosition

For this drawing algorithm, it uses the latest two positions to draw a point between them( between two updates), and Statue.interpolate is more like a ratio. This algorithm ensures the safety of the program because it only draws the point only after knowing positions of two updated point. The whole process of object moving would be smooth and object will never collide with something else. But this is also where the weakness stays as there will be a delay for graphics drawing because every point is drew behind the latest updated point. If the requirement of the sensitivity in reaction is high, this “delayed” smooth drawing will also produce a dull game play experience.

 

2. Forward Drawing

forward

 

drawPosition = drawPosition + velocity * State.elapsed

This kind of algorithm uses a predicted point as the drawing point. And one thing should be addressed, this algorithm is for linear movement. So by knowing the speed of the object( as velocity), we could predict what is the next position. To avoid the problem we talked about early (object stands still and then jumps!), this method could work. After the first update, we could  draw a predicted point and then wait for the second update. And there is certainly no delay. But the weakness is also obvious. As this algorithm is for prediction,  the collision is unable to avoid.  Let me explain this by the following pictures.

14D319F0-F49D-4414-84A5-5E5183C0B45F

 

The interval time between two updates is 1s. Let’s set the time of first update as zero second (0s), and we do not know in front of the object is a wall. So with the prediction, the second point has been drew at 0.5s ( just suppose). When the second update has been finished, then problem has come. According to the calculation, the object should be hit back by the wall. But now it has just passed through the wall. It  appears to penetrate the object! So this is a problem for this smooth drawing algorithm which has to be fixed.

 

3. Backward Drawing

backward

 

drawPosition = position + state.backward

 

This is similar to the second method, but this time we predict the past. Once we know a updated point, we could draw the point that should happen before it.  But in my opinion, this method is the worst. It has the delay, just like the first method and also it could put the object into something else. As we know the direction of speed may turn when a collision happens. If we use this method to predict the point, the point could be placed into the object which itself hit.  That is a huge problem and I do not look high of this method.

 

Expanded reading: http://www.gameprogblog.com/generic-game-loop/