Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -



Post new topic Reply to topic  [ 7 posts ] 
    Dahrkael
  Fri Jan 14, 2011 11:47 pm
VOC@LOID #01
User avatar
Member


Location: SPain :D
Hello everyone, some months after releasing my RubyENet online library some people asked me to make an example project using it, so they could see how things could be done and build a custom game on top of it. Today I finished filling the scripts with comments, so everything is easy to understand. So here it is:

RubyENet Game Template


This project shows how to integrate RubyENet into RPG Maker

This project is aimed to people who wants to add online functionality
to their games without to much trouble. This project includes the basic
structure to connect to a server, send and receive data.

It included:
- Methods to connect to a remote server
- Methods to receive and parse packets
- Other players in map
- Automatic global switches and variables
- Basic Chat
- A basic server for ruby 1.8.x and 1.9.x

Basic features to learn and build a solid and custom game on top of them

Explanation of what this project does:
- When clicked "New Game" the game connects to the remote server
- The server gives an unique ID to the game so it can be identified
- The game sends the player data to the server, who sends it to all the
other players, and returns the game the other players data.
- The players can interact throught switches and variables.
- Only players in the same map are updated and visibles.
- When another player disconnects, its deleted from the players list.
- If the game loses the connection to the server a warning appears.

All the new scripts are tagged as [Added]
All the edited default scripts are tagged ad [Edited]

Edited scripts and lines:
Content Hidden


Downloads


Project:
RPG Maker XP Project

Scripts:

____Added Scripts_____

ENet Module:
Expand to see the code.


Network Class:

Expand to see the code.


Game_NetPlayer Class
Expand to see the code.


Sprite_PlayerCharacter Class
Expand to see the code.


Sprite_NetCharacter Class
Expand to see the code.


Chat Class:

Expand to see the code.


Window_ChatInput Class
Expand to see the code.


Window_Chat Class
Expand to see the code.


Keyboard Module by Hound
Expand to see the code.



____Edited Scripts____

Game_Temp Class
Expand to see the code.


Game_Player Class
Expand to see the code.


Spriteset_Map Class
Expand to see the code.


Interpreter 4 Class
Expand to see the code.


Scene_Title Class
Expand to see the code.


Scene_Map Class
Expand to see the code.


Main
Expand to see the code.




____Extra Script____
Server Example:
Expand to see the code.



Additional Information and Notes



Servers can be done in C/C++, this can give a huge boost to your games
performance, also Server that doesnt display information (puts/print)
works faster.

This template connects to the server in Scene_Title when New Game is
selected.
The network is only updated in Scene_Map, if you are in another scene
the connection will be lost after 10 seconds or so. Update the network
in all the scenes you need.

The Chat input uses Hounds Keyboard Module,it uses this module because
it doesnt need external dlls, but its performance is pretty bad. Dont
think Chat is broken if you need to press the keys twice. It should be
rewritten using vgvgfs AInput module to get a perfect performance.

The RGSS Player stops updating the game when it doesnt have focus,
this is not a problem with TCP, where the stream just sleeps but ENet
uses UDP (which is a lot faster) and datagrams doesnt sleep. If the
game lose focus the connection will be lost after 10 seconds or so,
because the client isnt answering server petitions.
Workarounds:
- Use Win32API calls so the game has always the focus
- Make the game fullscreen so the player wont lose focus
- Hack the player so it updates without focus too

To fully understand how ENet works visit http://enet.bespin.org/


Comments, questions, petitions, fixes, etc are welcome.

_________________
You prefer 2D
Content Hidden

or 3D?
Content Hidden


Last edited by Dahrkael on Sat Jan 15, 2011 3:42 pm, edited 2 times in total.

Top Top
Profile      
 

    gerrtunk
  Sat Jan 15, 2011 2:43 am
Member

Interesting script but why you dont use alias in the default classes and methods?


Top Top
Profile      
 

    Dahrkael
  Sat Jan 15, 2011 1:53 pm
VOC@LOID #01
User avatar
Member


Location: SPain :D
gerrtunk wrote:
Interesting script but why you dont use alias in the default classes and methods?


Because the order is important, some things cant be at the beginning or ending of the methods. Said this, this isnt made for copy&paste&works, scripters oriented, they should know how to deal with it.

Edit:

Fixed the problem with ruby 1.9.x, now the server will run fine in 1.8.x and 1.9.x, faster servers, better gameplay.

Also added and ensure in main to instant-disconnect the clients who close the game.

_________________
You prefer 2D
Content Hidden

or 3D?
Content Hidden


Top Top
Profile      
 

    gerrtunk
  Sun Jan 16, 2011 1:12 am
Member

Also, what im thinking is that... ¿you are overwritting all that default methods? Every one of that? I readed some and are exactly like the default ones.

I suggest you to put just the methods you edit. I think thats better for scritpers they can learn in a few seconds what have been modified or not.


Top Top
Profile      
 

    Dahrkael
  Sun Jan 16, 2011 2:02 pm
VOC@LOID #01
User avatar
Member


Location: SPain :D
gerrtunk wrote:
Also, what im thinking is that... ¿you are overwritting all that default methods? Every one of that? I readed some and are exactly like the default ones.

I suggest you to put just the methods you edit. I think thats better for scritpers they can learn in a few seconds what have been modified or not.


Thats why i wrote this
Dahrkael wrote:
Edited scripts and lines:
Content Hidden



Some edits are just an added $network.update or such, yes.

Added: GetPeerIP method, so the server can print understandable dotted ips (127.0.0.1 for example).

_________________
You prefer 2D
Content Hidden

or 3D?
Content Hidden


Top Top
Profile      
 

    gerrtunk
  Thu Jan 20, 2011 12:37 pm
Member

Yes but better thant that is that you just put the methods you rewrite. Is still better for scripters, saves time and also improves de compatibility of your script because if an other script rewrites one of that methods that your script dont use it wont work...

Its just that i dont understand why to put that useless code here. The scene title have 6 methods and you only modifiy one...

Expand to see the code.


Thats better.

Also i dont know if your network class needs the rest but if you make an alias of the scene title new game method you gain compatibility with all the scripts that modify that, and also, reduce the lines of your script:


Expand to see the code.


Note that it may be valid to put it after the original in some scripts, but here is a scene transistion so i dont know if it will give problems...


Top Top
Profile      
 

    Dahrkael
  Thu Jan 20, 2011 5:19 pm
VOC@LOID #01
User avatar
Member


Location: SPain :D
As I said before, this is not intented to be a copy&paste&ItWorks. It doesnt even make sense to connect to the server when clicking new game. Its just an example. Each person uses what they want where they want. Alias are cool for non-scripters and quick-hacks, not for a serious game.

I dont get why do you waste time reading my-omg-so-bad-written-code :shock:

_________________
You prefer 2D
Content Hidden

or 3D?
Content Hidden


Top Top
Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 


Who is online

Users browsing this forum: No users and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

cron
We are an independent, not-for-profit game making community.
Homepage
Board Index
About Us
Downloadable Games
Free Browser Games
Games in Development
RPG Maker Support
Game Maker Support
Construct 2 Support
HBGames the eZine
Advanced RPG Maker
Site Announcements
Powered by phpBB © phpBB Group