# Search the Community

Showing results for tags 'walls'.

• ### Search By Tags

Type tags separated by commas.

### Forums

• HTML5 Game Coding
• News
• Game Showcase
• Coding and Game Design
• Frameworks
• Phaser 3
• Phaser 2
• Pixi.js
• Babylon.js
• Panda 2
• melonJS
• Haxe JS
• Kiwi.js
• General
• General Talk
• Collaborations (un-paid)
• Jobs (Hiring and Freelance)
• Services Offered

• 0 Replies

• 0 Views

### Interests

Found 4 results

1. ## phaser Rotating walls around the player.

Hello, so I'm trying to make it so that the player can 'rotate' the camera around them. For example when they press E and Q the world rotates and things like walls get repositioned and their angle changes. Here is the code I have written: function rotateWorld(angle) { for (var i = 0; i < walls.getAll().length; i++) { var wall = walls.getAll()[i]; wall.angle += angle; var delta_x = wall.x - player.x; var delta_y = wall.y - player.y; var thetaAngle = Math.atan2(delta_y, delta_x) * 180 / Math.PI; wall.x = player.x + lengthdir_x(distance(wall.x, player.x, wall.y, player.y), thetaAngle + angle); wall.y = player.y + lengthdir_y(distance(wall.x, player.x, wall.y, player.y), thetaAngle + angle); } } function lengthdir_x(length, direction) { return Math.cos(direction * Math.PI / 180) * length; } function lengthdir_y(length, direction) { return Math.sin(direction * Math.PI / 180) * length; } function distance(x1, x2, y1, y2) { return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); } So far this sort of works but objects lose proper positioning after rotating a bit. It seems like they are not rotating around a perfect circle. Any help would really be appreciated and if there is a way to do this that's easier please let me know. Thanks!
2. Hi guys, I'm a new student and I knew Phaser since 5 days and it's fantastic. So I'm a beginner. I'm trying to create one simple platform game, I have one issue but I don't know how to solve it. I'll appreciate your help. I need that when the animation hit the wall he changes the direction, right or left and keep running. Here's the part of the code that I think is necessary for analyses: // Collide the player with the walls var hitWalls = game.physics.arcade.collide(player, walls); game.physics.arcade.collide(stars, walls) //My animation starts running to right and I want it player.body.velocity.x = 200; player.animations.play('right',15,true); if (hitWalls) ???? { //Here I tried: player.body.velocity.x = -150; but the animation is crazy now } Thanks and have a good day!
3. I have a problem in plotting points when trying to create WALLS. The problem in dissection : - I have 4 points in XOZ plane That I want them to produce 4 walls, as each 2 points are a line and I want each line to become a wall by computing the other 2 points of the wall. I assume the height of the wall (3 meters, for example). This wall might contain holes later (Doors & Windows). Finally I need an enclosed room. I want to create these walls without importing from blender, I get those points from elsewhere. Here is the steps, I use to solve the problem: 1) I split the array into 4 lines. Each line contains 2 points. 2) I have to compute the 2 other points for each line. and here is the problem. I used the dimension Y which is wrong when using ExtrudedPolygon Object. So I have to work in the same XOZ plane and rotate. Here I face other problems like How to calculate the angle of rotation? plus the way of computing the 2 other points will be through having 2 data : The length of the wall (3 meter for example) and the angle which is also a variable that depends on the slope of our line. Here is a sample of my try: https://www.babylonjs-playground.com/#SF0BN6 You can find that in the last loop, I create a wall but with points that contain a Y dimension, which resulted in corrupted shape, But I hope to avoid the suffering of Computing the other 2 points in the same XOZ plane which enforces me to respect the slope of the line and so on as I illustrated in the second point. If you have any alternative ideas, I welcome that. Thanks in advance.