Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entities don't move #19

Closed
bates64 opened this issue Nov 5, 2016 · 9 comments
Closed

Entities don't move #19

bates64 opened this issue Nov 5, 2016 · 9 comments
Assignees

Comments

@bates64
Copy link
Collaborator

bates64 commented Nov 5, 2016

image

@towerofnix
Copy link
Owner

Pretty sure that's on top of the block still. The real issue is the mushroom block isn't moving!

@bates64 bates64 changed the title Entities don't fall? Entities don't move Nov 5, 2016
@bates64
Copy link
Collaborator Author

bates64 commented Nov 5, 2016

That's what I meant 📦

@towerofnix
Copy link
Owner

Mushroom just runs Powerup's constructor with the arguments passed to its own constructor.

Here's the constructor for Powerup:

constructor(game: SLW, x: number = 0, y: number = 0, xv: number = 1)

And here's the line that's constructing Mushroom:

const [x, y] = this.game.level.getAbsolutePosition([this.x, this.y])
let shroom = new Mushroom(this.game, x, 0)

In that case the xv defaults to 1, so it should be moving.. I wonder if xv is getting reset (or slowed down too quickly) somewhere..?

@towerofnix
Copy link
Owner

PS I don't know entirely how that constructor call works lol

@bates64
Copy link
Collaborator Author

bates64 commented Nov 5, 2016

It does have xv when it's created- it jumps across. As soon as it hits the ground, however, it stops..

@towerofnix
Copy link
Owner

So I guess xv is getting reset to 0 every tick, once it's touched the ground, before xv is actually used?

@towerofnix
Copy link
Owner

towerofnix commented Nov 5, 2016

Think of it like this:

/* Do Y-velocity handling stuff.. */
// (An equivalent to) this happens once the mushroom
// has touched the ground, and on every tick after the
// mushroom's touched the ground:
this.xv = 0
/* Okay, done doing Y-velocity handling stuff.. */

/* Do X-velocity handling stuff.. */
// Huh, this.xv is 0, so don't do anything!
if (this.xv) {
  // whatever
}
/* Okay, done doing X-velocity handling stuff. */

xv gets reset every onUpdate before the player is moved horizontally. Once it gets to the step of moving the player horizontally, xv is 0 and therefore it won't move horizontally.

@towerofnix
Copy link
Owner

Of course the question is why this doesn't effect the player sprite, and why it does effect the mushroom sprite - I assume it's because of a bad Y position....

@towerofnix
Copy link
Owner

towerofnix commented Nov 5, 2016

Okay, the issue is this.collides() is being used instead of some left/right wall detection - I assume collides is detecting the floor..

edit: relevant code:

for (let i = 0; i < Math.abs(xv); i++) {
  this.x += v
  if (this.collides()) {
    this.x -= v
    if (stop) this.xv = 0
  }
}

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants