Questions tagged [p5.play]

p5play is a JavaScript game engine that uses p5.js for rendering and Box2D for simulating physics.

Learn more about p5play at p5play.org

20 questions
8
votes
1 answer

how do i make the canvas perfectly fit to the window size in p5

i want to make the p5 canvas fit perfectly to the window size, but whenever I use windowWidth and windowHeight , the canvas seems to be bigger: is there any way to fix this?
PineInDisguise
  • 103
  • 1
  • 7
2
votes
1 answer

How to use mouseX and mouseY to remove a sprite

Using p5.js / p5.play I'm trying to click a moving sprite, but stuck on how to get the moving sprites coords and position. At the moment when I click anywhere on the canvas a random sprite disappears. I've been trying to use mouseX and mouseY. Very…
1
vote
1 answer

Doesn't mousePressedOver() detect touches from mobile too, If doesn't what function to use instead?

This is the line I'm facing with, I want to detect mouse click when being used in PC (which is working completey fine) and to detect clicks when used in mobile too. if (keyDown("left") || mousePressedOver(left)) { sofia.velocityX = -1 …
Drew
  • 11
  • 1
1
vote
1 answer

p5.play dynamic objects moving towards each other and stopping without bouncing away from each other

Im trying to program a Age of War like game. This game is programmed in p5.js with the p5.play library. Im having trouble having sprites moving towards each other and stopping and then activating a function. I'am currently changing the collisions of…
1
vote
1 answer

How do I change the scrolling bg to top to bottom?

Im trying to make a scrolling background of stars for my game in p5js. I've found code that makes the background scroll vertically from bottom to top but i want it backwards. How do I fix this? let ship; var bgImg; var x1 = 0; var x2; var…
Sam Apers
  • 11
  • 1
1
vote
2 answers

P5.Play - Collision problems

hoping someone can help me with this. I'm trying to create a game where balloons get popped by bullet. Sort of similar to balloons tower defence. My only problem is that the frames are drawn every 60 seconds and each loop happens once per 60 seconds…
Telesto
  • 23
  • 4
1
vote
1 answer

how to display animation after sprites collide/overlap using p5.js/p5.play

I am trying to display an animation when a collision occurs between sprites. I have asteroids that I shoot and when I shoot them the asteroids disappear when the bullet collides or overlaps the asteroid. I would like to play an animation after the…
Yakob
  • 159
  • 1
  • 7
1
vote
2 answers

Draw an image from an array value p5.js

I am fairly new to p5.js, however I am trying to read a .txt file which contains the below text, and draw a picture depending on the value within the .txt file. 00000 20022 00222 22020 11111 I am currently stumped as to how to draw an image…
David1163
  • 11
  • 1
1
vote
1 answer

placing sprites using an array

I am trying to place sprites on a canvas using an array however I an unable to get the sprites to draw correctly. function preload() { fileContent = loadStrings('track.txt'); grasssprite= loadImage('grass.png'); tracksprite= loadImage…
1
vote
1 answer

TypeError: Cannot read properties of undefined (in P5js / p5.play.js)

Uncaught TypeError: Cannot read properties of undefined (reading 'touches') at p5._main.default._updateTouchCoords (p5.js:78864) at p5._updateNextTouchCoords (p5.play.js:265) at p5._onmousedown (p5.play.js:302) I am…
1
vote
0 answers

How do i rotate a sprite towards the mouse in p5.play?

i'm makig a top-down shooter game using the p5.play(p5) libraries. I want to rotate the player sprite towards the mouse. with the Atan2 function(https://p5js.org/reference/#/p5/atan2). i managed to rotate an image using this. but when i try to…
PineInDisguise
  • 103
  • 1
  • 7
1
vote
1 answer

Rotation facing mouse not correct with p5 libraries

i am making a javascript shooter game.i want the the player to rotate towards the mouse.it is working, but the rotation was not correct. I tried this with an image, and it works, but with the sprite itself(player1), is not. i have asked this once…
PineInDisguise
  • 103
  • 1
  • 7
0
votes
0 answers

Button is not functioning properly and moving off of screen once clicked by user

I'm trying to code a really simple game using p5.play. In it, once a button is pressed, four sprites are expected to move off screen to display a separate screen. For some reason, when the button "You received a letter!" is pressed it shows the…
0
votes
1 answer

Problems with collision checking in p5.play

im remaking the game "outlaw" in p5.js with the library p5.play, the problem is that whenever i try using the functions:collided and collides. it dosnt work, heres the piece of code that dosnt seem to be working: if(player1.collided(bullet2)){ …
0
votes
0 answers

Data does not update in firebase

so I have been working on a piano game where two people compete against each other and press notes as fast as they can. The game should end when one of the players reaches a certain score, but the database is not updating the game…
1
2