This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

bourne
bourne presents ...

2014/1/9

Two Player UserInfo

Beta: A reusable utility for onsite user 2-player games. Provides user online status, opponent selection, client communication, etc.

This demo scenario features the Tic-Tac-Toe game with an instant messenger.

Please feel free to reuse this utility to make your own onsite user 2-player games (just include in the description the appropriate credit).
And same for the GUI Components.

Needless to say, likes/votes are always appreciated.

Note, my utility replaces UserInfo (in that UserInfo should not be used on the side)

The classes that are required for using TwoPlayerUserInfo are:
- TwoPlayerUserInfo
- BitStringUtil
- MessageContents

** NO live-action multiplayer **
Live-action is not feasible! It is not possible to get updated information to clients fast enough using UserInfo!
Turn-based and similar styles are what this utility was meant for.

** TwoPlayerUserInfo’s EFFICIENCY using UserInfo **
- While paired with opponent - getNearby(3) is called to retrieve list of user data containing data for opponent.
- While in the lobby (opponent selection) and during the pairing process with opponent - getTop is called to retrieve full list of user data.

** Overhead **
TwoPlayerUserInfo reserves the score field and the last int field for its operations. As well as the last String field but only during the pairing process with opponents (meaning it still can be carefully used to store data, and of course to be included for a message).
A score can be stored in another int, and a full list retrieved through TwoPlayerUserInfo can be sorted by it (to create a highscore table etc.)

** Opponent Selection / Lobby **
Only users that are online appear in list (should always give a few moments as it listens for user activity).
Use help button for more info.

** TO-DO **
- More documentation.
- Ironing out things.


For a collection of onsite user multiplayer games, visit:
http://www.greenfoot.org/collections/404

For reusable GUI Components, visit:
http://www.greenfoot.org/scenarios/7578

5155 views / 1046 in the last 7 days

4 votes | 0 in the last 7 days

Tags: demo with-source 2-player reusable gui userinfo messages bourne

open in greenfoot

There is no HTML 5 translation of this scenario available.
View legacy version (requires Java plugin)

This scenarios uses Java features that are not available for use after conversion to HTML 5. Please try the legacy version, which requires the Java plugin to be installed.

bournebourne

2014/1/9

@lordhershey, I forgot to add something to end the game if it is a cats game =( Though you can always press '1' to return to lobby.
A new version of this scenario was uploaded on Sat Jan 11 19:09:40 UTC 2014 Testing instant messenger for in-match. Also added indication of cat's game for playing tic-tac-toe, incorporated in "activity" log where chat messages display. As well as indication if no longer paired with opponent.
bournebourne

2014/1/11

Fixing bugs...
A new version of this scenario was uploaded on Sat Jan 11 19:45:05 UTC 2014 More testing...
A new version of this scenario was uploaded on Sat Jan 11 19:49:38 UTC 2014 More testing...
A new version of this scenario was uploaded on Sat Jan 11 19:57:34 UTC 2014 Bugs fixed
bournebourne

2014/1/11

This is probably the easiest networking 2-player gets. And there is a lack of interest and excitement... Oh well, I will move on to other projects like always
PhilASPhilAS

2014/1/13

Can you tell me exactly how I can find other players to play with? We tried to find each other in the same LAN but the game simply doesn't show any player in the Lobby...
bournebourne

2014/1/13

This utility is built on top of UserInfo which stores to a Greenfoot server. So it must be able to communicate with it. In the comment above I should have said "onsite user" 2-player networking.
A new version of this scenario was uploaded on Thu Jan 23 05:23:16 UTC 2014 Added two methods to the BitStringUtil class to aid in encoding/decoding data at the bit level for the String fields of UserInfo. The methods are: evaluateBitString(String) and evaluateToBitString(String)

See all comments

Want to leave a comment? You must first log in.

Who likes this?

Game/maniac MrHam JetLennit lordhershey