diff --git a/ProjectFinal1/readme.md b/ProjectFinal1/readme.md new file mode 100644 index 0000000..e7e4919 --- /dev/null +++ b/ProjectFinal1/readme.md @@ -0,0 +1,57 @@ +game + +- game.Load + - game.Start + - game.Loop + - 初始化 wall,bean,goldBean,player,monster + - 初始化 dir = dir_none + - while(1) + - key = GetKey() // 获取按键输入 + - switch(key) + - p pause + - q quit + - w dir_up + - s dir_down + - a dir_left + - d dir_right + - other dir = last_dir + - player.PlayerMove(wall,dir) // 玩家根据按键输入移动 + - player.NextMove(dir,nx,ny) //预测下一时刻玩家的坐标 + - 根据nx,ny,判断下一时刻玩家是否撞墙 + - be careful! you must have to ensure nx or ny is at last one is an integer, if not, you can't move according to the input direction + - ofcourse, you can be a little tolerent, as an example, when the input direction wants to change ny, but nxis not an integer, but , maybe nx is so close to an integer, you can force it converting to an integer, and then change the ny + - if you obey these rules, you can move the player, + - player.Move(dir) //调用函数移动玩家 + - clear its image at the old (x,y), + - then set the new (x,y) according( nx, ny), and draw its image at the new (x,y) + - if(player.PlayerMove is successful) //如果上一时刻玩家成功移动(没撞墙) + - player.TryEatBean(bean) // 玩家尝试吃豆子 + - include 2 parts ,first , judge player is or not meet a bean, + - then, eat the bean and add player's score, and return true + - if( successful) // 玩家尝试吃豆子成功 + - bean.IsEmpty? && goldBean.IsEmpty? + - if(true) + - game over, player win + - player.TryEatGoldBean(goldBean)// 玩家尝试吃金豆子 + - include 2 parts, just same as above + - if(successful) // 玩家尝试吃金豆子成功 + - bean.IsEmpty? && goldBean.IsEmpty? + - if(true) + - game over, player win + - change all of monster's status + - change all of monster's speed + - monster.TryEatPlayer(player) //怪物尝试吃玩家 + - include 2 part, first, judge monster is or not meet the player, + - then judge who is win according to monster's status , and (player win)change the player's score or (monster win) game over, player lose + - monster.MonsterMove(wall,player) + - according to monster.status, make different choice: chase or escape or waitingBorn + - dir = chase(wall, player) + - according to player.GetX & .GetY & wall, choose the move dir + - dir = escape(wall, player) + - get contrary dir by chase(wall,player) + - dir = waitingBorn(wall) + - monster.Move(dir) + - clear its image at the old xy, then set the new xy according pre_x, pre_y, and draw its image at the new xy + - just like what player.Move(dir) has done + - 恢复地形 + - game.End \ No newline at end of file