BUG: svn r571 breaks pushable block behavior

BUG: svn r571 breaks pushable block behavior

Postby acme_pjz » 07 Feb 2013, 17:22

I tested it, found that the bugs regarding squashing and moving a block through scripting is not fixed but it breaks pushable block behavior. :| Bug occurs when you move when standing on pushable block
Some of my open source games on GitHub
User avatar
acme_pjz
 
Posts: 665
Joined: 10 Dec 2009, 15:32
Location: PeeKing, China

Re: BUG: svn r571 breaks pushable block behavior

Postby Edward_Lii » 07 Feb 2013, 19:28

Hello acme_pjz,

acme_pjz {l Wrote}:I tested it, found that the bugs regarding squashing and moving a block through scripting is not fixed but it breaks pushable block behavior. :| Bug occurs when you move when standing on pushable block

I found the source of the bug, basically I tried to generalize the getBox method, but it didn't end up that well.
Anyway, it the pushable blocks should work properly again in svn rev. 573. ;)

You also mention that the bugs regarding squashing and moving a block through scripting isn't fixed, could you give a test case for this.
Every block should now go through the same "squash" detection, so if a case doesn't work with scripting it shouldn't work in the same block layout without scripting. :|

Also when debugging the collision system it seemed that pushing a pushable block to the left will result in the player standing with a 1px gap from the block, but pushing to the right to a 2px gap.
Not sure what is causing this and if this has been the case since the start of pushable blocks... :think:
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: BUG: svn r571 breaks pushable block behavior

Postby acme_pjz » 08 Feb 2013, 06:53

I mean the squashing is correct, but walking on script-controlled block is (still) incorrect, here is an example:
{l Code}: {l Select All Code}
name="Script Test"
size=800,600
tile(Block,0,100)
tile(Block,50,100)
tile(Block,200,100){
   id=block1
   script(onCreate){
      script="
      block1=block.getBlockById('block1')
      print('onCreate, test result: ',(block1==block.getBlockById('block1')))
      "
   }
}
tile(Button,100,100){
   behaviour=toggle
   id=0
   script(playerIsOn){
      script="
      local x,y=block1:getLocation()
      y=y-1
      if y>=0 then block1:setLocation(x,y) end
      "
   }
}
tile(Button,150,100){
   behaviour=toggle
   id=1
   script(playerIsOn){
      script="
      local x,y=block1:getLocation()
      y=y+1
      if y<=550 then block1:setLocation(x,y) end
      "
   }
}
When the block is moving up, walking on the block is incorrect :| I think we should look at the code of movable blocks and copy some code from it, maybe write some common subroutine/game logic...
Some of my open source games on GitHub
User avatar
acme_pjz
 
Posts: 665
Joined: 10 Dec 2009, 15:32
Location: PeeKing, China

Re: BUG: svn r571 breaks pushable block behavior

Postby acme_pjz » 08 Feb 2013, 08:18

I found another bad squash bug :? See the attached video
Attachments
20130208_1506_26.avi.zip
(39.25 KiB) Downloaded 315 times
Some of my open source games on GitHub
User avatar
acme_pjz
 
Posts: 665
Joined: 10 Dec 2009, 15:32
Location: PeeKing, China

Re: BUG: svn r571 breaks pushable block behavior

Postby Edward_Lii » 08 Feb 2013, 17:08

Hello acme_pjz,

acme_pjz {l Wrote}:When the block is moving up, walking on the block is incorrect :| I think we should look at the code of movable blocks and copy some code from it, maybe write some common subroutine/game logic...

I think I know what is causing this problem and I'm afraid it's quite tricky to fix.
The velocity of a moving block is determined by it's delta movement since the last frame.
I did the same for every other block, which made squashing work and standing on it, but when the block stops the delta (and therefore the velocity) is still pointing upwards.

IMHO the best solution would be to use dx/dy for the delta box and xVel/yVel for the velocity box.
Each block has its responsibility for making sure these values are correct in the move method.
The default behaviour for non-moveable blocks should work when moving through scripting.

If all works out as planned the collision system should work in all cases regardless of the block type. ;)
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: BUG: svn r571 breaks pushable block behavior

Postby Sauer2 » 08 Feb 2013, 18:45

How about something like moveBlock(block1, x, y, speed) which is a reference to a C++ routine, which adds the block to a blocks-to-move list in the C++ code and have a the blocks in the list moved on the common update process?

EDIT: Forgot speed.
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: BUG: svn r571 breaks pushable block behavior

Postby Edward_Lii » 08 Feb 2013, 20:47

Hello Sauer2,

Sauer2 {l Wrote}:How about something like moveBlock(block1, x, y, speed) which is a reference to a C++ routine, which adds the block to a blocks-to-move list in the C++ code and have a the blocks in the list moved on the common update process?

Well this is an idea, but I like to have the collision routine work in all cases independent of the block types.
Basically there should be no block type checks in the collision detection part of the move method.
All collision handling should be based on the requested box types (Current, Delta, Velocity) and all blocks need to make sure they set the corresponding variables correct each frame.
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: BUG: svn r571 breaks pushable block behavior

Postby acme_pjz » 09 Feb 2013, 08:01

Edward_Lii {l Wrote}:I think I know what is causing this problem and I'm afraid it's quite tricky to fix.
The velocity of a moving block is determined by it's delta movement since the last frame.
I did the same for every other block, which made squashing work and standing on it, but when the block stops the delta (and therefore the velocity) is still pointing upwards.


Yes, I also found that, and tried reset dx/dy every frame in 'Block::move()' function, but it didn't work :|
Some of my open source games on GitHub
User avatar
acme_pjz
 
Posts: 665
Joined: 10 Dec 2009, 15:32
Location: PeeKing, China

Re: BUG: svn r571 breaks pushable block behavior

Postby Edward_Lii » 10 Feb 2013, 15:13

Hello acme_pjz,

acme_pjz {l Wrote}:Yes, I also found that, and tried reset dx/dy every frame in 'Block::move()' function, but it didn't work :|

The problem was that the script was executed in the move method of the player/shadow.
So the delta variables weren't reset in time.

This should be fixed in the new collision system: http://forum.freegamedev.net/viewtopic.php?f=48&t=4182
The pushable blocks on the other hand are broken...
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Who is online

Users browsing this forum: No registered users and 1 guest