quinton-ashley / p5play

JavaScript game engine that uses q5.js/p5.js for graphics and Box2D for physics.
https://p5play.org
GNU Affero General Public License v3.0
666 stars 184 forks source link

Spritesheets not working correctly #190

Closed karlcleveland closed 3 years ago

karlcleveland commented 4 years ago

While experimenting with p5.play, I keep running into issues with sprite sheets not functioning correctly. If I role back the version of p5.js to the 2016 version used in the online examples, it works fine. But, sprites sheets don't work correctly in the current version of p5.js (v1.1.9). For example, the exact code/files used in the online example for sprite sheets (http://molleindustria.github.io/p5.play/examples/index.html?fileName=sprites_with_sheet.js) will not function with the current build of p5.js.

SnipedCode commented 4 years ago

I posted the solution to this on Oct 30, 2018 look for issues "Sprite sheets not working correctly with p5.js >= v0.5.5"

did you try it ?

karlcleveland commented 4 years ago

Thank you! That worked for the animated sprites. But, as referenced in #136, the tile_sprite_sheet did not work because it is not animated and uses a different function (drawFrame). So, it appears that in addition to line 3571, line 3926 also needs to be updated from:

pInst.image(this.image, frameToDraw.x, frameToDraw.y, frameToDraw.width, frameToDraw.height, x, y, dWidth, dHeight);

to:

pInst.image(this.image, x, y, dWidth, dHeight, frameToDraw.x, frameToDraw.y, frameToDraw.width, frameToDraw.height);

With these two changes, everything works.

socalledsound commented 4 years ago

just adding a +1 to this! drawFrame() is at line 3954 for me, in the currently available download from the p5.play site, and this fix fixes it. Did you submit a PR karl?

myselfhimself commented 3 years ago

Does a PR fix this ?

molleindustria commented 3 years ago

Perhaps @islemaster will know the answer. This has been a recurring issue that seems easy to address. Is there a reason the proposed fix wasn't merged?

molleindustria commented 3 years ago

Alright, I figured out how to github and the fix has been implemented, hopefully it doesn't break other things...