Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - seyuup

Pages: [1]
1
General / Kinematics - Grid Jumping Problem
« on: July 06, 2017, 03:24:41 pm »
Hi, I hope that someone will be able to assist me with my problem.

  • I have an object that moves from grid to grid (left, right, up, or down) at a speed, s.
  • The grid is 32x32.
  • There are "holes" scattered around the grid map. These holes can only be passed by jumping over them.
  • Each hole is also, 32x32
  • I want the object to be able to jump over these holes, but I want the jump movement to last the time it takes for the object to move from grid to grid.

I'll let, d, represent the direction (either x or y) that the object is moving. Thus,
  • ddisplacement = 32 (since each grid is 32x32).
  • t = ddisplacement / dspeed * elapsed time (as seconds)

Here, t, should be time it'll take for the object to cover the displacement, ddisplacement (in pixels), at speed, dspeed.

I then proceed to finding gravity amount:
  • jumppower = 100.f.
  • V0z = jumppower (the initial velocity in the 'z' direction).
  • Zdisplacement = 0 (the displacement of the jump).
  • gravity = 2 * (V0z * t - Zdisplacement) / t2

Notice: I'm not sure if the elapsed time needed to be applied here when calculating gravity.

Finally, I attempt to calculate the height at time, tother.
  • Before jump:
  • tother = 0 (this is set once before the jump executes).
  • ...
  • height = Z0 + V0z * tother + 0.5 * gravity * tother2.
  • V0z += gravity * elapsed time (as seconds).
  • tother += elapsed time (as seconds).
  • ...
  • Height applied to the sprite
  • sprite.setPosition(x, y + height)

Once again, I'm not sure if I applied the elapsed time correctly here. After attempting this, however, it appears to keep the object in the air of the length of traversing grid space to grid space, but the jump movement isn't what I'm going for.

When I press the key to make the object jump, object gradually moves upward, but then drops like a rock. I would like for it to be a nice smooth movement (like Super Mario Bros.).

Sorry, if this entire post was confusing, please let me know where any confusions may lie so I can try to help you all understand my problem better.

Thanks!

2
Hello, I've been trying to build SFML from source over the past few days (I'm used to just using Visual Studio, but I wanted to try using CLion with MinGW-w64.

While following the build tutorial on the main site, I unfortunately encountered an error that I have no idea how to solve. Here is Cmake and the error.



I hope someone will be able to share some insight on helping me solve the issue.

3
General / Square grid path-finding approaches
« on: March 05, 2016, 10:19:34 pm »
Hi, I'm currently trying to implement game play where a player and an enemy are snapped to the grid and the enemy will constantly find a path to the player (even while the player is moving). The entities can only move in the directions left, right, up, and down.

1.) My first approach was to implement path finding using Breadth-first search (no thread).

The game lags (of course) because the computer is having to do too much work.

2.) My second approach was to implement path finding still using Breadth-first search except this time using a thread.

Using a non-detached thread, the game doesn't lag anymore, however, the enemy freezes at times (I assume from trying to calculate the constant movement).

I choose to find a new path only when the enemy is snapped to the grid and when the last found unused path is retrieved by the enemy controller.

Any ideas on another approach to this problem? I'm only going to have one enemy which constantly calculates a path to the player. I'll try to post some code later today.

I hope someone will be able to assist me!

Update (3/5/2016 8:12 PM):

I was able to fix the problem. It was a logic error, fortunately. I was checking for a path based on the player's (x,y) position (which can be a float value) instead of integer values divisible by the grid's (width, height).

Pages: [1]