Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [HELP] Multiplayer distance calculator, how to?

Author
Message
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 10th Jun 2013 10:57
Hi all,
i have this problem...

We have 3 devices resolutions :
- 1136x640
- 960x640
- 1024x768

Now if i create my fighters in (DEVICE_WIDTH / 2) - sprite_size - 384 and in (DEVICE_WIDTH / 2) + 384 they are equally far the same on all devices.

Now, i'm sending the controllers on the net, to avoid much bandwidth. In this way my multiplayer is really fast, but when the resolutions are different, the pixel the player walk are different.

I thought to do a formula like this:
MPlayer : Multiplayer Player
Me : Player 1
Move : the base pixel of movement (3px)

1024 : move = 1136 : x

so

Me : move = MPlayer : x

x = (Mplayer * move) / Me

new_px = 3px * x

But they move in really different way.
I don't know why.
Anyone of you have a solution or know how i can do?
Thx!

Long life to Steve!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Jun 2013 11:42
Scale the movement proportionately.

If you move 3 units in the 1136px resolution (we'll call this the base movement), then to calculate the movement step on the other devices is as follows:


x = (3*960) / 1136 = 2.535
x = (3*1024) / 1136 = 2.704


Since not all devices have the same aspect ratio, you'd probably want to do the same for vertical movement as well.

xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 10th Jun 2013 17:15
Hmmm, it is not really precise but work better.
I need to do some other tests.

Long life to Steve!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 10th Jun 2013 17:31 Edited at: 10th Jun 2013 17:31
maybe alternatively you can use at all devices the "same" virtual resolution (1:1 Pixel) but different zoom.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 10th Jun 2013 23:30 Edited at: 10th Jun 2013 23:33
For my case i use a "Development resolution" (of 1920x1080 ...) then i use the detected Screen Height and Width and i use two simple short named functions to move (or size) elements (i know i'm a lazy guy :p)

Then i can easily set fixed screen positions/sizes for my element according to my dev screen size and adapting them automagically to detected screen size on other devices.

Here is an example : (obviously you can do this in other ways as said before)

xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 12th Jun 2013 01:36
Thx buddy, i will test it in this way too.

Long life to Steve!
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 12th Jun 2013 13:36
Wow it work perfectly!!!
Thx buddy!!

Long life to Steve!
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 12th Jun 2013 14:02
Which solution ?
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 12th Jun 2013 14:24 Edited at: 12th Jun 2013 14:25
Your solution, to give a bigger resolution as base.
This work perfectly in multiplayer!!!!!

I done in this way:
When the game decide who is host and who is joiner they send each other the respective resolutions.
And he do the calculations when the direction arrive.
Really simple and fast!!!!

Long life to Steve!
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 13th Jun 2013 02:58 Edited at: 13th Jun 2013 03:00
Yes and it is more accurate than a percentage (but with floats you could have done it with a percentage in your network messages ... but they will be longer ... so more network traffic)

Login to post a reply

Server time is: 2024-04-27 15:14:50
Your offset time is: 2024-04-27 15:14:50