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.

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 26th Feb 2013 10:44
hi, I am trying to have a host player controlling a tank and a client controlling another both with a virtual joystick, the code so far seems to move the same sprite for both host and client for reasons I don't know but I have probably done something wrong! any help please?





Hail to the king, baby!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th Feb 2013 15:21
Believe it or not I'm doing a tank game for fun but haven't quite gotten around to the network commands yet. Otherwise I'd be happy to share.

Perhaps try checking that the message you are using was intended for that user. It's possible you are reading your own message to set the position?


this.mess = abs(sin(times#))
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 26th Feb 2013 16:57 Edited at: 26th Feb 2013 16:58
yeh,they can be fun to play, i thought of some awesome powerups to implement, when i finally work out this network stuff, i did try following the online help but noticed it riddled with mistakes, unless it is for an older agk, but it used vars like Type which isnt allowed as that is actually a valid command of course, and another var called message which is an absolute nono, after renaming them the sodding thing still didnt work!!

Hail to the king, baby!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th Feb 2013 17:54 Edited at: 26th Feb 2013 17:56
Attached is my game in a very raw state. WASD to move and mouse to aim and fire. Multi-player is disabled at the moment as it's not finished and splitscreen only works broadcast to a touchscreen device at the moment.

EDIT: Alt-F4 to exit (no exit button yet )


this.mess = abs(sin(times#))

Attachments

Login to view attachments
Grayvyn
15
Years of Service
User Offline
Joined: 30th Oct 2008
Location: Southern California
Posted: 26th Feb 2013 19:50
I think you got the sprite numbers mixed up in these functions. I made the change.



shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 26th Feb 2013 21:07
well..it has improved,i can now move the clients tank which shows on the host screen, i can move the host tank which also shows on the host screen but fails to move on the clients screen!

Hail to the king, baby!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 26th Feb 2013 22:12
i begin some changes but can't test because want watch movie yet
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 26th Feb 2013 23:08 Edited at: 26th Feb 2013 23:12
thanks for that markus, i tested it,i personally am using 2 different colored tank images for each sprite, the code you gave doesnt show the host sprite moving on the client window, it shows the client sprite moving on the host window all be it the wrong colored tank!

Hail to the king, baby!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 26th Feb 2013 23:17
I think the sample Markus put up assumes that one color is used for 'your' tank and the other for the 'enemy' tank. This seems somewhat intuitive.

But in some ways, not quite. Recently we got Worms for iPad (we being my daughter, her boyfriend, my husband and myself) and you can play a game with all four on your own iPad using bluetooth (not too bad). In that game, all of the participants need to see exactly the same colors for each team.

The code could be modified so that you store a flag indicating whether the local game is host or client. Also, at the point that the user selects one, set global variables for the local and remote tanks appropriate to host/client. On the client local would be red (1?) and remote would be purple (2?). On the host, local would be purple (2?) and remote would be red (1?).

Then the GetInput and SendUpdate commands would use local and the GetUpdate command would use remote, instead of the hard wired values.


Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 26th Feb 2013 23:41
hmm,well an improvement again,thanks, but it seems to not want to move the host sprite onto the client, just moves it on the host, client moves on both and at least is now the right one..i think... hehe

Hail to the king, baby!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 27th Feb 2013 09:14 Edited at: 27th Feb 2013 09:24


shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 27th Feb 2013 14:13 Edited at: 27th Feb 2013 14:17
ah damn! that is fantastic marcus, thanks for all your help you have given me, could you point out where i was going wrong so i can learn,perhaps adding some rem statements in english! And also I presume this only works for local network right? i understand one needs to run a server for anything global,which i could setup as i know abit of mysql/php, but it is just setting it up code wise also, I have a pretty good level editor I have been working on and it is just a matter of combining the two and moving foreword i hope,i will post a video of the level editor when i get the chance,it allows for placement,rotation and saving positions of sprites but is in a rather basic state at the moment,but hell it works ok!

Hail to the king, baby!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 27th Feb 2013 16:18 Edited at: 27th Feb 2013 20:32
ok,
i change the network message send parameter to client=0 , it sends to all expect self.
for internet connections i write the other join command in this example. you can make a third button in the lobby.
(for connections over web you must understand the windows firewall and router configuration.)

shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 28th Feb 2013 10:17
this is a very nice start for me, thanks again markus,i was thinking that using param returning from functions as the best way of doing this instead of the crude way i chose, which just got me lost and confused in the end! Will probably put in the level loading functions with the saved level data file and see how all this polishes up now

Hail to the king, baby!
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 28th Feb 2013 15:09 Edited at: 28th Feb 2013 15:15
ok i have joined them together but ran into some other problem, i am using physics for collisions with tanks/walls , which means that a tank could in effect push another tank if they are both dynamic(i set the physics gravity to zero so they won's drop of course) but this pushing effect from physics collision does not update on both screens!

I have attached my project media file with the level data in it and this is the code so far:






I had to modify some of your previous code to coincide with the way the level editor makes the data file as far as what numbers sprites are assigned to

Hail to the king, baby!

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Feb 2013 16:52
i think the best way is that the host do the position and
send all positions to the clients.
the client send his joystick to the host and the host
move this tank and later send the position back.
for physics better use force & impulse because the setspriteposition skip the physics.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Feb 2013 16:55
Yes, Markus is right, it's far less likely to cause inconsistencies if the actual game is run on one machine and the rest just show the results.


this.mess = abs(sin(times#))
swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 1st Mar 2013 01:08
Baxslash - I played you little WIP there. A few notes...
-The camera movment is slow on epic proportions haha makes me a little sick You might want to add a sense of urgency to the camera repositioning.

-The tank is appropriately sluggish. Although, as far as game play goes (I'm not sure what your target is) I fear that would really retract from the skill component of the game.

-Blowing out walls is cool and stuff, but I'd suggest dividing the map's destruction detail up 1 more notch because the blocky chunks look quite silly when the cool debris clears.

swis
Joined: Tue Dec 16th 2008
Interstellar
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 1st Mar 2013 11:38
yeh that is pretty impressive Baxslash, far more than what i had planned, was this done with the 3d or 2d part of agk, i realise the tank looks 3d but of course could just be rendered frames!

Hail to the king, baby!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Mar 2013 12:37
@swissolo - Thanks for playing. Yes, I already sped up the camera quite a bit. I quite like it being a little slow but it was too much I agree.

I've added a speed pickup which will give the player a boost for a while but I am happy with the speed of the tanks under normal circumstances at the moment.

I tried taking the blocks up several notches and it soon slows down on the iPad (even went down to 1 pixel in size). What I might do is change the minimum size slightly but with the shadows I've added it actually looks OK now IMO.

@shadey - Thanks! Yes, it's all 2D although I am considering a 3D version at some point using the same engine.

Anyway I don't want to drag your thread off topic too much so I have created a WIP thread for my game here: IronGun

If you have any questions on how to achieve anything I'm doing in my game just ask and I'll be happy to share.


this.mess = abs(sin(times#))
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 1st Mar 2013 15:06
thanks man,i am not too clear on what markus last said,i sure would like an example on it coz admittedly this network stuff is way over my head! I feel i ain't creative enough to do a single playered game, yet it seems overly beyond my skills to do a multiplayer game! I am sure beginning to think the core problem is lack of brain cells! of which there is no known cure

Hail to the king, baby!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Mar 2013 15:13
Don't worry, it seems pretty hard at first but the more you program the better you'll get. The network stuff only just bumps the top of my head


this.mess = abs(sin(times#))
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Mar 2013 10:31 Edited at: 2nd Mar 2013 10:33
the first step is to add a command name in the message.
then you can make a select case with it.
its just a name like "init" "pos" "lobby" "pause" "getallposition".
now you have only sendupdate, its not enough.

example:

Login to post a reply

Server time is: 2024-05-03 02:08:08
Your offset time is: 2024-05-03 02:08:08