• Create Account

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a \$50 Amazon gift card. Click here to get started!

# Shayel

Member Since 22 Mar 2013
Offline Last Active Nov 19 2014 03:22 AM

### Rotating collision boxes

06 October 2014 - 08:38 AM

Hello
Let me start with a simple explanation of my collision system. Every object in my game is just a sprite with a defined vertexes. For example a triangle block is made of 3 vertexes. The collision between a ball (that is my player) and the triangle is done by calculating shortest distance between every edge of the triangle, and every edge is made of 2 vertexes. I am sure you know what  I mean.

Until now everything was fine, but now I want to rotate some of the objects. And here comes the problem: when rotating the sprite, how to calculate new positions for for the vertexes.

Picture as an example. Red dots are the vertexes for calculating collision. Blue dot represents anchor, around which the sprite rotates (so the sprite rotates around its center). (1) is the object without any rotation. After the rotation i want to move the vertexes so they fit the actual display (2), and not stay as they stood before (3). I would appreciate any help

##EDIT##
I was messing around with a piece of paper and probably found a solution. Every vertex <-> center distance is const. Assuming that I increase angle by 5 degrees i can use basic trigonometry (sinus and cosinus) to calculate new X and Y for every vertex.

Correct me if I am wrong. Also I don't know how calculating sin/cos every frame would consume the processing power. I am afraid it would be pretty devastating for the processor (creating a mobile game). Another idea is to keep x/y offsets for every vertex, for every degree, for every type of object. Like a mini-database. But... duh.. i hope there is a better solution..

### Type of networking in platformer game

14 September 2014 - 01:46 AM

Hi

I want to learn a bit of how multiplayer works in gamedev. To do so I am making a simple platformer game with a coop feature. I don't really know where to start. I was thinking of a client-server architetcture, where first player creates the game and the second one joins it. The only thing client would do is sending input to the server and drawing. So all of the calculations would be done on the server side. But that seems strange to me.. any tips on how to implement networking in a 2D platformer?

### Strange memory allocation bug with new[]

27 December 2013 - 08:02 AM

Hi

I have ran into a strange problem..

I have this piece of code:

```template <class T>
void my_vect<T>::myAlloc(size_t dim)
{
try
{
dat=new T[dim];
}
{
err::MyErrorHandler.Error(ALLOC_ERROR);
}
}
```
Later "dat" is causing the heap corruption, even if it shouldn't. After many many many hours of figuring out why, I found out that the value of my "dat" pointer isn't the same as the value returned by the new[] operator (found it out by stepping into the new operator and looking what it returns). For example new returns 0x...e18, but "dat" is 0x...e1c. The offset is always 4 bytes long. This causes my program to fail when using for example _msize() function.

Why is it happening?

### Using global variables - really so bad?

03 October 2013 - 12:28 PM

Hi
Ill give you an example.

```g_SoundSystem;
class Game
{
sf::RenderWindow screen;
State* CurrentState;
public:
void Start()
{
CurrentState->Logic();
}
};

class Level1
{
Player player;
public:
void Logic()
{
if(something) g_SoungSystem->Play("shot.wav");
}
}

CurrentState=new Level1();

```

I heard that global variables are bad.. but what is the other way to use things like "Soundsystems" etc. g_SoundSystem has to be global so i can use it from any place in the program. I was also thinking about setting flags in certain points but that would also require global access. In other words: Can you help me in understanding how to replace globals?

### Pathfinding, graph algorithms

19 June 2013 - 01:41 AM

Hello
I am trying to understand the basics of the pathfinding, but I don't understand the main idea. I understand how the algorithms work, for example A* algorithm. The thing that confuses me is how do I actually set the vertices. Let's say I have a tile-based map in a 2D game. Do I set them manually , for example in my level editor, and store the coordinates of the vertices in the array/list/tree/anything?

PARTNERS