Search the Community

Showing results for tags 'math'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

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

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 39 results

  1. Hi all, This may be an easy question but I cannot seem to solve it myself after several attempts. For my Model Train Simulator in BabylonJS I'm creating a helix/spiral track, allowing trains on a lower section to quickly gain altitude within a short area (e.g. climbing a mountain). This is often used in 'hidden' sections on model train displays to have a train pass a valley track and next pass a mountain bridge which is position much higher (Y position) in the scene. When I construct the points of a helix/spiral using the formula from the docs https://doc.babylonjs.com/babylon101/parametric_shapes https://www.babylonjs-playground.com/#165IV6#61 And then use Path3D on these points to get the normals see the docs https://doc.babylonjs.com/how_to/how_to_use_path3d https://www.babylonjs-playground.com/#2DLXYB#1 https://www.babylonjs-playground.com/#8ICWNU Then I get an ever increasing cant/superelevation of my track, see the blue arrows in the picture which indicate the 'up' vectors. The result is that the track at the top has a cant. I use the Tangent, Normal and Binormal from the Path3D of the line/points to set the track rail and bed geometry, and position the train always perpendicular to the track (that is: up). But I want to have the Up vector always Vector3.Up(), or at least that there is no cant/superelevation and I can continue placing 'flat' track with it's normal Vector3.Up() on the top. The big blue arrow indicates Vector3.Up(). Current 'vector up' results from Path3D in my game: Blue = up vector (from Path3D). Large blue with _ = helix direction (Y axis) Yellow line through track = Line through the spiral center points (radius * cos t, radius * sin t, ascentfactor * t) Desired 'vector up' on the spiral/helix: (image found at http://www.easyhelix.com) Hope someone knows how to 'alter' the results from Path3D so I get the helix point orientation but without the cant/superelevation. So that I can 'lay the track' properly without trains 'falling off the track' because of cant/superelevation. Bonus questions: - the yellow marked area in the skybox marks another bug that is caused with a reflection texture intersection with the skybox. the default background color comes through on the waves. - the red box marks a mesh (air balloon) with a physics impostor that is already moving, but I want the physics computation to be paused until the user presses some 'start to play'-button, instead of physics computation right from the moment the scene is loading Happy coding, Q
  2. Play Cool Math

    Math Mahjong Relax

    Welcome to online Math Mahjong Relax. Math Mahjong Relax is a traditional solitaire game where you have to take apart the construction made of dice. The game helps to improve your attention, speed and math skills. Dice differ in the image on the upper edge. With one move, you can get only two same and open dice. The dice is considered open if its left or right face is open. The game includes 36 levels from simple to complex ones. In the beginner levels you will learn the rules, find out which dice differ and which ones can be interchangeable. Online Math Mahjong Relax iOS Math Mahjong Relax Android Math Mahjong Relax
  3. Play Cool Math

    Math Number Challenge

    Math Number Challenge In this game, you need be finding figures for speed. It looks quite easy for the first time. However, at every level new tasks appear complicating the search for numbers. In the game, you will learn figures in the decimal system. You will find out how to count to 10 with Roman figures. Moreover, you are going to learn to quickly search for figures matching the sides of the dice. Some figures (in complex levels) are represented as arithmetic expressions and you will have to calculate the amount or difference before to choose the right number. Play Online Version Play iOS Version Play Android Version
  4. Play Cool Math

    Math Tower of Hanoi

    Based on this classic puzzle, we created a game called Math Tower of Hanoi. The game contains of 18 levels - from simple ones to complex ones. The smallest disk has number 1 on it, the next disk is larger and has number 2 and so on up to the largest disk that has number 8, accordingly. The main goal of this game is to move the disks so that the amount of the digits on all the disks in the bars would match the target. The fewer steps you make during the game, the more points you will get for the puzzle. You are allowed to move only one disk at a time. You cannot put a larger disk on a smaller one. You will get other math tasks between the levels. Play and improve your skills in mental counting. Online Version Android Version iOS Version
  5. Does anyone know how to rotate a sprite from it's current rotation? I'm having a Math brain fart. Here is my Sandbox example of the issue: http://phaser.io/sandbox/HhWNhhmR/play The sprite rotates around it's center when you drag it, but it always snaps to the mouse. How can we rotate it from where it currently is? I would love to have it respond in a similar way that PropellerJS works. As a bonus, it would be awesome to add the inertia and stepped angle constraints. Thanks!
  6. Play Cool Math

    Math Pixel Puzzle

    Math pixel puzzle is a very unusual game. The rules are very simple. You will see an image with pixels of various colors. After three seconds, the pixels fly apart in 3D space. Your task is to rotate the space so that the image appears as originally. In the upper left corner you will find a hint - a small picture. You’ll need to collect an image so that it becomes exactly the same as the one in the hint. If it gets upside down or inclined – let’s look for more options to solve this puzzle. The difficulty of the levels increases at every level. In this game, we collected figures from 0 to 9 and pictures of geometric shapes: circle, square, triangle, parallelogram, cube and star. Do not spend too much time as it is limited. The faster you solve the puzzle, the more points you will get. Game Play Video https://www.youtube.com/embed/wuCh4hVShZI Cordova Project for iOS and Android Google Play pluging GameCenter plugin Heyzap plugin (admob, UnityAds) Firebase plugin Play Math Pixel Puzzle Online Download Math Pixel Puzzle on AppStore Get Math Pixel Puzzle on Google Play
  7. Play Cool Math

    1024 Math

    1024 Math Remix on classic game 2048. 1024 Math reminds a game of 2048 from Gabriele Cirulli. There are 18 levels in this game. You need to complete all the goals when you get at each level. https://playcoolmath.com/en/math-games/1024-math Play 1024 Math
  8. I spent around 4 hours scratching my head and still can't figure this out! If you throw an object in front of you and then move left or right, how can you tell which side you are on? I'm using BabylonJS so it would be super helpful if you could limit the methods used to that library. Otherwise, a clear mathematical question would suffice. Thank you so much!
  9. cpuheater

    Math Addict

    Hi All, Math Addict - is a fully responsive HTML5 Game, combine at least two numbers to equal to the given number. https://www.brainler.com/math-addict-game regards
  10. Hi All, This is my first game using PhaserJS ,packed using cordova. Math Mind – is a mathematical game in which you have to solve a lot of interesting numerical problems within the given time duration, test your Math Mind on various numerical operations and, if necessary, to develop this skill.Game Features: - Three Game Modes- Find the Operator - in this math game mode you have to find the correct operator which will make the given number from the other two numbers.;- Find the Number - in this math game mode you have to find the missing number which will make the given number provided a number and an operator.;- Geek Mode - This level is for Geek Math Mind Peoples as it has three types of questions randomly appearing.;This Math Game makes the math fun.Its free to download. IOS version coming soonplease download and rate us it will help me in looking into more game development. Play Store Link : https://play.google.com/store/apps/details?id=com.DP.MathMind
  11. Raggar

    Server-side Hit Detection?

    This is my current setup: .Player presses the Mouse button .A Ray is fired using Babylon and the players camera The intersection point (vector3) is sent to the server The server uses Cannon to do it's own intersection testing (Using the player's head hitbox(Same location as the camera client-side) as the origin point, and the vector3 from the client as the target point. Now, if I wanted the server to be a bit more authoritative when it comes to hit detection, I shouldn't send the point from Babylon, but rather a 'fire' command, and, somehow, calculate a point that Cannon can use for it's own testing. The server is aware of the position of the origin vector, and has the rotation of the player's physics body. Now, my math is worse than bad, so: Would it be possible to calculate a point, a fixed distance away, using only the origin vector and the direction in which the point should be placed? I've seen various posts and discussions about it, but I really don't quite get it. Oh. And I know aimbotting isn't impossible to prevent, but I feel like the above method, that I already use, makes a bit too easy to achieve.
  12. I'm doing a label system, you can see the original post here. I don't think it's relevant but you get the background. To make it work, I created various faces on a mesh. Each faces generate a label. To know which one has to be displayed, I would like to compare their angle to the camera to know if it's facing the camera enough to be visible. After some research I came with this : http://www.babylonjs-playground.com/#QNJ03P#1 I'm pretty bad in 3D math but I already found some usefull posts and PG on the forums and the doc. - I think I'm pretty close but I don't know why my camera Quaternion doesn't seems to be refreshed when I rotate the camera (except for the Y axis which switch btw 0 and -0). - Also I'm not sure how to compare both quat so that I can say if the difference is less than 40° I can display it - And finally when I apply the function toQuaternion() on the ground it rotates it. I have the same issues with my faces and I don't know if it will changes something or not. Could someone give some insight to finish this ?
  13. We just released our latest game: Number Tumbler! (We're really betting on people liking to tumble things, I guess) It's a mathematical game about adding numbers! A number crunch in a time crunch is what we're calling it. Our unnofficial slogan for the game is "It's more fun than it sounds! Really, we swear!" ... at least one of us on the team really needs to get better at copy writing. If you're interested in trying it out, you can play it on our website (on your computer, phone, or smart refrigerator) https://lumoludo.com/numbertumbler Or download it in app form on your favorite mobile device (provided that your favorite mobile device isn't a Windows Phone) https://itunes.apple.com/us/app/number-tumbler-number-crunching/id1155829197?ls=1 https://play.google.com/store/apps/details?id=com.lumoludo.numbertumbler On a side note, I was just reading the Phaser newsletter yesterday and saw that Emanuele Feronato is releasing their DrawSum game on the app store. Man, we hadn't seen DrawSum before yesterday, but I guess it's just poor timing on our part we happened to just finish such a similar game at the same time. If you take the time to play it, we'd love to get your feedback! Any comments, criticisms, and (most importantly!) praise will be graciously received. Thanks!
  14. Hi Again, Let me explain what I'm trying to do first: I want a panel of 3D objects which line up along the left-hand side of the canvas/viewport. I'm trying to create an object factory of sorts. The user will click and drag objects from the object factory into the scene proper, the code will clone the selected object when this occurs. I'm using two scenes for this, one is the main scene, with a ground and control-enabled camera receiving the clones and accumulating state; and another scene, for the factory, that is essentially static but has a camera and lights and meshes (the factory prototypes). As I've said, I want this factory to be arrayed down the left-hand side of the screen. If I choose just any position for the factory objects, they will go into and out of scope when the canvas aspect ratio changes. So I want to be able to calculate a ray which vertically cuts the camera's left-hand viewing-frustum plane, say somewhere in the middle, parallel to the near and far edges. I think this should be a vertical slice, abutting the left edge of the viewport. Here's how I tried to do it: First, I tried using getFrustumPlanes. But the planes it gave me were oddly skewed. When I generated geometric planes for each of the six, for instance, they did not form a convex solid. And even when I mentally tried to figure out which plane was which part of the frustum, I just couldn't make sense of the numbers. I would have expected 2 along each camera-centric axis (e.g. + & - along X, + & - along Y, + and - along Z--I setup a straight-on camera to help in understanding the numbers to no avail). Next, I tried a few of the unproject methods. I think these methods should have converted a 2D point on the screen to a 3D point (or ray) in the world. I read through many posts on this site to use what I thought were the best values for the camera's projection matrix, world matrix (identity), etc.... Never got anything even close to good numbers. Mostly they were NaN until I saw one post which accessed maxima from the engine. But when I positioned my mesh (using a sphere) at the returned 3D vector, it always seemed to go to the same, incorrect place (irrespective of my choice for 2D starting point). Next, I successfully wrote an iterative algorithm which used many of the same transformation matrices along with project. This way, I would choose a 3D point, test where it was in 2D, and knowing the fixed orientation of the camera, choose another 3D point which projected closer to the 2D point for which I was aiming, etc.... Sort of like a newton's method for iteratively approaching the correct value that unproject should give me in fixed time. OK, I can do it, but I want to do it correctly. So my last attempt, for which I have a playground, uses: createPickingRayInCameraSpace. I think this should give me a ray which looks like a point, but really rides the intersection of the left and top viewing-frustum planes (because I choose 0,0). However it does not. Playground demo: http://www.babylonjs-playground.com/#1CHH2O#1 Please help. I don't care if I use any of these methods. Is there a better way? Should I be using the aspect ratio directly? Should I just do my own matrix math? Thanks, Ken
  15. I need some help with color math. I am trying to create height maps in code... i can read raw terrain data and get the float raw height value for each pixel (x,y) as a value from 0 to 1 0 being black and 1 being white. I need to convert that 0 to 1 float to a black and white pixel based on the level of 0 to 1. Here is an example code block.. I need to basically create a Color.FromFloat type function as listed below: Texture2D duplicateHeightMap = new Texture2D(terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight, TextureFormat.ARGB32, false); float[,] rawHeights = terrain.terrainData.GetHeights(0, 0, terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight); /// run through the array row by row for (int y=0; y < duplicateHeightMap.height; y++) { for (int x=0; x < duplicateHeightMap.width; x++) { // height map color (0 to 1) float rawHeight = rawHeights[x, y]; // NOTE: HERE IS WHERE I NEED HELP (MAYBE GRAYSCALE ???) Color color = Color.FromFloat(rawHeight); duplicateHeightMap.SetPixel(x, y, color); } } // Apply all SetPixel calls duplicateHeightMap.Apply();
  16. Hi all, I know it isn't really babylon related, but there are a lot of smart guys around so i believe it to be worth a try and ask I have been working on & testing some area calculations, mainly for finding meshes within a certain select area, think "area of effect" game abilities. Examples; For a square area, I simply use two vector3's, one containing minX, minZ and the other one containing maxX and maxZ, thus creating a virtual square which you can use to check if any meshes are found within it. Resulting in a very lightweight & simple solution. For a circular area, I use a starting middel point of the circle (x & z position), and a pre-set radius/distance value and then i calculate & check distance to meshes and select all meshes which are valid and in-range, But now to the issue at hand, Finding a cone area; Basicly, a small select part of a circle area, calculated depending on a player's rotation.y, a pre-set radius/distance value and a pre-set "width" value. Visualization; So in the above visualization, if a mesh was found within the cone area shown in the "width" illustration, it should be a hit, but if it was outside the defined area, it should be ignored, even if the mesh is within the circles radius.. How would you go about doing this? I have setup a PG containing the basic circular calculations, (open browser console for code feeback). http://www.babylonjs-playground.com/#2KMFW6#5 I appreciate any help & ideas.. Cheers.
  17. GaryS

    Detect sectors of a circle

    So, circles are confounding me today... About twenty years ago I did GCSE maths and remember wondering when or why I would ever need to know any of this stuff about circles and angles and the like. Now. Now is when I need to know all that stuff. So I've been all over the interwebz and have learned lots about circles, but while there are myriad explainations of how to work out the length of an arc, the angle and area of a sector... and use both radians and degrees to calculate same; I can find nothing that will tell me which sector a given value (theta, radian, degree, whatever) is in. If I've divided my circle into 12 segments, can I pass a value and know that it belongs in sector 3, for instance?
  18. I found myself making a class called MatrixComp, which is the rotation, translation, & scaling components of a BABYLON.Matrix broken out. When trying to scale the matrices of a pose from a library, more than just scaling the translation is required to account for skeletons which might have different postures / builds (rotation at rest). Otherwise, the skeleton assumes the posture of the skeleton used to make the library, which can look weird. I added methods to compute the ratios of each component's rest value (called basis) to the rest value that of the library. Often, the translation of a dimension is zero, so using the divide function results in a NaN. I wrote my own, shown below. Is there any interest in changing the division behavior to this? a NaN is really not useful. this.translationBasisRatio = BABYLON.Vector3.Zero(); if (libraryBasis.translation.x !== 0) this.translationBasisRatio.x = this.translation.x / libraryBasis.translation.x; if (libraryBasis.translation.y !== 0) this.translationBasisRatio.y = this.translation.y / libraryBasis.translation.y; if (libraryBasis.translation.z !== 0) this.translationBasisRatio.z = this.translation.z / libraryBasis.translation.z; Also, there is no divide for a Quaternion, but this equivalent. Maybe, a wrapper? this.rotationBasisRatio = this.rotation.multiply(BABYLON.Quaternion.Inverse(libraryBasis.rotation)); I also ended up with my own versions of Vector3.LerpToRef & SlerpToRef. I am fine keeping all of this in my code, but some could be moved if wanted.
  19. This is a math question, or maybe a question for someone who understands how billboard modes work under the hood. Given a long thin mesh with a texture of a chain, how can I position it so it looks like a chain stretches between two arbitrary positions? Here is a playground that shows sort of what I'm shooting for (until you rotate the camera, anyway). Just imagine the mesh in the middle has a texture on it like a chain or a rope. The main point is to have the "chain" mesh appear to stretch from one position to the other, while keeping its planar surface facing the camera (so that it doesn't get thin and disappear depending on the viewing angle). My instinct was this might be possible with some combination of rotation and billboard modes. If not, I guess it will be necessary to take the camera's position into account? Or if there's a simpler way to achieve what I want, that'd be great. Thanks!
  20. var game = new Phaser.Game(1024, 600, Phaser.auto, 'phaser-example', { preload: preload, create: create, update: update, render: render }); var result = 'Press a key'; function preload() { //load assets game.load.image("single_turret","./img/single_turret_64x64.png"); game.load.image("mouse","./img/mouse.png"); } function create() { //start physics game.physics.startSystem(Phaser.Physics.P2JS); single_turret = game.add.sprite(400,300,'single_turret'); mousep = game.add.sprite(50,50,'mouse'); //enable psysics on all items and enable debugged game.physics.p2.enable([single_turret,mousep], true); mousep.body.setCircle(4); mousep.body.kinematic = true; single_turret.body.setCircle(4); single_turret.body.kinematic = true; } function update() { } function render(){ game.debug.text(result, 32, 32); mousep.body.x = game.input.x; mousep.body.y = game.input.y; lookAtObject(single_turret, mousep, 0.005); } function lookAtObject(obj, target, rotspeed){ var angle = Math.atan2(target.body.y - obj.body.y, target.body.x - obj.body.x); result = obj.body.rotation + '**'+ (angle + game.math.degToRad(90))+ '**'+obj.body.angle; obj.body.rotation = angle + game.math.degToRad(90); } The code above rotates the "turret" to always be pointed towards the mouse so that it can fire at the mouse position. The code works, but I want to add a rotation speed to it, however I can't figure out how to code that in. The lookAtObject() function is where I have the problem. function lookAtObject(obj, target, rotspeed){ var angle = Math.atan2(target.body.y - obj.body.y, target.body.x - obj.body.x); result = obj.body.rotation + '**'+ (angle + game.math.degToRad(90))+ '**'+obj.body.angle; if (obj.body.rotation <= angle + game.math.degToRad(90)){ obj.body.rotation += rotspeed; }else{ obj.body.rotation -= rotspeed; } } This statement does not work as intended because of how p2js works, so when It gets at ( -x , 0) the radians go from -1.5 to 4.7 and the rotation will reverse. I am really stumped atm, so any ideas on how to approach this?
  21. Forgive me, because this isn't a game. I'm a high school computer science teacher and I was looking for an online 4-function binary calculator to explore bit math with my students. I was disappointed with what I found online, so I made one here, using Phaser: https://bitcalc.org/ The calculator does everything in actual bitmath, meaning the addition and subtraction functions process the two numbers bit-by-bit with regrouping, and the multiplication and division functions are iterations of the first two. Might be of interest to somebody. Source: https://github.com/jgordon510/bitcalc
  22. I trying to create a "perfect" hexagon... that is in a fact a perfect hexagon for games, and I'm failing at it. This is what I got so far var game = new Phaser.Game(1024, 600, Phaser.AUTO, 'Phaser', {create: create, render: render}); var arr = []; var graphics; var cx = 300; var cy = 200; var size = 64; var result; function create() { graphics = game.add.graphics(0, 0); for(var c = 0; c < 6; c++){ arr[c] = hex_corner(cx, cy, size, c); } //draw vertices for(var c = 0; c < 6; c++){ graphics.lineStyle(1, 0xffd900, 1); if (c != 5){ graphics.moveTo(arr[c].x, arr[c].y); graphics.lineTo(arr[c+1].x, arr[c+1].y); }else{ graphics.moveTo(arr[c].x, arr[c].y); graphics.lineTo(arr[0].x, arr[0].y); } } //draw points for(var c = 0; c < 6; c++){ graphics.beginFill(0xFF0000, 1); graphics.drawCircle(arr[c].x, arr[c].y, 10); } result = 'height:' + (arr[1].y - arr[4].y) + ', width:' + (arr[0].x - arr[2].x) ; } function render(){ game.debug.text(result, 32, 32); } function hex_corner(center_x, center_y, size, i){ var coord = {}; var angle_deg = 60 * i + 30 ; var angle_rad = Math.PI/ 180 * angle_deg; coord.x = center_x + size * Math.cos(angle_rad); coord.y = center_y + size * Math.sin(angle_rad); return coord; } The "edges" are not the same size, the width is not same and if I rotate it in the middle of a hex grid for instance it will be out of bounds. So how do I make a perfect hexagon for any fixed size with equally sized edges, equal height and width? This is what I would like to achieve. A hexagon with the corners outside of the circle.
  23. ricardocouto8

    Calculate fastest side to rotate

    Hello guys! Probably more a math problem than a phaser one, but still I'm breaking my head finding a solution. Maybe you can help me! Imagine I have a sprite pointing towards the direction of the red arrow. I want to make the sprite rotate slowly towards the pointer (in this image the green arrow), and to have it rotate clockwise/counter-clockwise depending on which way is faster (in this case counter-clockwise). How can I calculate if the faster way is clock/counter-clockwise, providing the sprite can be pointing wherever and the pointer could be anywhere? If I was not clear I can try to clarify better Thanks in advance!
  24. Hi Everyone, This is my fist post on the Babylon.js subforum, and I must say that I am really loving the framework! Recently, I have been following this article by Andy Gainey: http://experilous.com/1/blog/post/procedural-planet-generation#cylindersAndSpheres His original code is in Three.js, however I do not need all of his code, I just adopted the portion of the code that generates a subdivided Icosahedron. I am running into some difficulties generating and rendering the compound polyhedron of this icosahedron (such that each new vertices of the mesh are the centroid of each face of the Icosahedron). I have it so that I render the compound polyhedron, however it has the following issues: The triangles that compromise each face are blatantly obvious I need to render the face both ways (duplicate the indices in reverse), because some faces don't render if I don't do that I becomes slow compared to the icosahedron generation. There are excessively more vertices generated than required (however I want to be able to color each face individually) Here is the github repo with the code: https://github.com/PranavSathy/planetgen Lines of interest are: 335-353 : They order the face centroids of the Icosahedron to generate the hexagons/pentagons 355: Inserting the face indices for rendering into the indices buffer I look forward to your opinions/suggestions, thanks everyone!
  25. The link http://www.askforgametask.com/mobile/games/matchsticks/ Description Matchsticks: Endless Digit Hunter is an HTML5 one-button matchstick (aka toothpick) puzzle/logic game in which your goal is to rearrange all given math equations and make them true by moving just one match. The game can be played on 4 different levels of difficulty: Normal - the equations contain numbers from 0 to 9. Medium - the equations contain numbers from 0 to 19. Hard - the equations contain numbers from 0 to 49. Insane - the equations contain numbers from 0 to 99. On each level there are 5 faulty math equations which must be corrected as fast as possible! All equations are procedurally generated so the levels are always different. To make the given equation true, tap on a match and move it to the right place. For each bad move you get a penatly of 10 seconds! The game can help you to improve your math skills. You can run it on your desktop or mobile browser. Screenshots