Jump to content

  • Log In with Google      Sign In   
  • Create Account

P0jahn

Member Since 21 Nov 2012
Offline Last Active Nov 26 2015 04:29 AM

Topics I've Started

Find tile coordinates within a given radius

31 August 2015 - 08:41 AM

I am developing a game where the top left corner of the world is coordinate 0:0. Thus, x is increasing while moving right and y down.

 

I am trying to come up with an algorithm that finds the coordinates of the tiles within the given circle.

 

The method signature could look like this:

 

ArrayOfCoordinates findCoords(int centerX, int centerY, int radius)

 

Example, if radius is set to 1, it would search something like this:

Attached File  pic1.jpg   38.93KB   0 downloads

 

If it is 2:

Attached File  pic2.jpg   40.89KB   0 downloads

 

And 3:

Attached File  pic3.jpg   44.12KB   0 downloads

 

4:

Attached File  pic4.jpg   48.6KB   0 downloads

 

And so on.


Iterate through the boundaries of an rotated rectangle?

29 July 2015 - 03:28 AM

I am developing a game where a rectangles position is the top-left corner where x is increasing rightwards and y downwards.

 

What I am trying to achieve is to iterate through the boundaries of an rotated rectangle. Did some googling with no luck.


Best way to store a stage for a platformer?

09 July 2015 - 06:36 AM

In my current game, coded in Java, I store it in a 2D byte array(width, height). Each element is the size of a pixel.

 

When the stage gets large, the amount of ram used for it as high as 150 mb.

 

I dont know if this is the best approach. Any suggestions of an better way to store a stage efficiently? 


Coding a chain for a 2D Game

09 November 2014 - 03:58 PM

I want to code a chain for my game and am not sure how to do it so I am hoping to get some suggestions that get me started.

 

Details:

You create a chain object and specify two points: start and end point. 

The image of the chain object is one piece of the chain. Example:

Attached File  ring_228_00.png   4.47KB   0 downloads

 

So it should look something like this ingame:

Attached File  example.png   27.63KB   0 downloads

 

Ideas?


Formula to calculate when a point is reached

14 October 2014 - 07:51 PM

I am developing a 2D game where x is increasing rightwards and y downwards. Thus, the top-left corner is 0,0.

 

I have an enemy that moves towards a set of waypoints. When one is reached, it will start moving towards the next waypoint in the list.

 

I use the following code to move towards a point:

	Vector2 norP = normalize(this.x, this.y, target.x, target.y);
			
	float accelx = thrust * -norP.x - drag * vx;
	float accely = thrust * -norP.y - drag * vy;
		 
	vx = vx + delta * accelx;
	vy = vy + delta * accely;
			
	this.x += delta * vx;
	this.y += delta * vy;

That piece works fine. The problem is detecting when a point has been reached.

 

Right now, I use the following:

if(distance(this.x, this.y, target.x, target.y) < 25)
{
     ...

The value 25 is a fixed value and works sometimes. As you alter thrust and drag properties, the value 25 stops being effective.

So I need a formula that calculates this value that works good no matter what thrust and drag is(taking them into consideration).


PARTNERS