Bug 583 - The Sprite disappear after it is surrounded but not died
Summary: The Sprite disappear after it is surrounded but not died
Status: RESOLVED FIXED
Alias: None
Product: CS3343_Kunkun_Loves_English
Classification: Unclassified
Component: Game Object (show other bugs)
Version: 1.0
Hardware: PC Mac OS
: --- major
Assignee: xuezhwang2-c
URL:
Depends on:
Blocks:
 
Reported: 2021-11-20 11:20 HKT by konolmyda
Modified: 2021-11-20 11:32 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description konolmyda 2021-11-20 11:20:49 HKT
Summary: 
Hi, I found that when I was playing the "GRE" version of the game (I guess it is also applicable to other version), when the sprite is surrounded, i.e. it still has some places to move, but it can never go to the boundary. The sprite on the screen just disappeared.

Steps to reproduce:

1. Enter the login scene and click the "GRE" button
2. In the GRE game,
   click basketballs at (5,7), (5, 8), (4, 5), (4, 7), (4, 6), (6, 5), (6, 7), (6, 6) in order and enter correct word.

Expected outcome:

After the sprite is surrounded but not died, the picture displayed should be angry cxk.

Actual outcome:

After the sprite is surrounded but not died, nothing is displayed at the sprite's location.

Guess:

I guess the reason is because there is some mistake in loading the pictures from file system in the game object Dio.
Comment 1 xuezhwang2-c 2021-11-20 11:31:34 HKT
(In reply to konolmyda from comment #0)
> Summary: 
> Hi, I found that when I was playing the "GRE" version of the game (I guess
> it is also applicable to other version), when the sprite is surrounded, i.e.
> it still has some places to move, but it can never go to the boundary. The
> sprite on the screen just disappeared.
> 
> Steps to reproduce:
> 
> 1. Enter the login scene and click the "GRE" button
> 2. In the GRE game,
>    click basketballs at (5,7), (5, 8), (4, 5), (4, 7), (4, 6), (6, 5), (6,
> 7), (6, 6) in order and enter correct word.
> 
> Expected outcome:
> 
> After the sprite is surrounded but not died, the picture displayed should be
> angry cxk.
> 
> Actual outcome:
> 
> After the sprite is surrounded but not died, nothing is displayed at the
> sprite's location.
> 
> Guess:
> 
> I guess the reason is because there is some mistake in loading the pictures
> from file system in the game object Dio.

Hi, Mingyang!

This is the original code inside class Dio.java:

	public void recomputeShortestPath(boolean shouldMove) {

		if (isAlive()) {
			MapNode dir = null; 
			//whether change to surround from normal / death from surround
			if(!isTrapped) {
				s = new ShortestPath();
				MapNodeInfo info = node.getNodeInformation();	
				dir = s.computeDecision(info.abstractPos);
				if(dir==null) {
					setSurround(true);
				}
			        if(isTrapped()) {
				        dir = moveSurround();
			        }
			}
			if(dir!=null && shouldMove) {
				setNode(dir);
			}
		}
	}

The problem is that the code segment to judge whether Dio is trapped (surrounded in your language) is inside the code segment if(!isTrapped), this means that after you update the information of boolean variable trapped. moveSurround will directly be executed without first change the update().

I fix this bug by change the code into the following:

	public void recomputeShortestPath(boolean shouldMove) {

		if (isAlive()) {
			MapNode dir = null; 
			//whether change to surround from normal / death from surround
			if(!isTrapped) {
				s = new ShortestPath();
				MapNodeInfo info = node.getNodeInformation();	
				dir = s.computeDecision(info.abstractPos);
				if(dir==null) {
					setSurround(true);
				}
			}
			if(isTrapped()) {
				dir = moveSurround();
			}
			if(dir!=null && shouldMove) {
				setNode(dir);
			}
		}
	}