Comments (9)
So I guess xv
is getting reset to 0 every tick, once it's touched the ground, before xv
is actually used?
from slw.
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
}
}
from slw.
Pretty sure that's on top of the block still. The real issue is the mushroom block isn't moving!
from slw.
That's what I meant
from slw.
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..?
from slw.
PS I don't know entirely how that constructor call works lol
from slw.
It does have xv
when it's created- it jumps across. As soon as it hits the ground, however, it stops..
from slw.
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.
from slw.
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....
from slw.
Related Issues (20)
- Add death state HOT 4
- World Map HOT 14
- Uglify removes `debugger`
- Add lint check for line length HOT 2
- Add control buttons for mobile devices HOT 2
- Small player spritesheet HOT 1
- Jumping through solidTop blocks is jittery HOT 2
- Punching a block doesn't reset yv
- Add invisible block HOT 2
- Go through pipes HOT 2
- Destroying a level doesn't remove entities HOT 1
- Can't build HOT 9
- Level editor? HOT 11
- Moving up on world map causes airpunch event
- entityUpdate should be renamed to updateEntities
- WASD controls HOT 1
- Level saving HOT 13
- Editor camera position HOT 1
- Crouching / Ground-pounding
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slw.