You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

jayess

Trainee

  • "jayess" is male
  • "jayess" started this thread

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

1

Monday, April 19th 2010, 11:55pm

ORPG in Jabaco-applet

Hi all,

I have put together a multiplayer game I made awhile back in VB, now into Jabaco-applet form. I would like to share my sample with everybody as I feel it is a good to show how powerful Jabaco is vs VB. The sprites, tiles, and sounds I did not make (obviously)... however.. I wanted something classic to use in it for now. I also moved over the map editor for Jabaco-applet form. There is a daemon for the server, and its source still sits in VB6. There are also a few other utilities I made that go along with it all too to make things easier.

You can see the applets at http://www.tecktronic.net/jrpgt


8)

Sincerely,
Jason

This post has been edited 4 times, last edit by "JasonS" (Nov 16th 2011, 3:56am)


Tobias

Beginner

  • "Tobias" is male

Posts: 12

Date of registration: Mar 31st 2010

Location: Sweden

Occupation: Programmer / Network tech

  • Send private message

2

Tuesday, April 20th 2010, 8:28am

Sounds like fun! Thanks for sharing!

Aaron

Beginner

  • "Aaron" is male

Posts: 7

Date of registration: May 1st 2010

Location: Scotland/United Kingdom

Occupation: Student

Hobbies: Computer Programming

  • Send private message

3

Sunday, May 2nd 2010, 9:44pm

Could you give a tutorial on this, explaining how it works?
Much appreciated - Aaron.

"Intellectual growth should commence at birth and cease only at death."

jayess

Trainee

  • "jayess" is male
  • "jayess" started this thread

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

4

Monday, May 3rd 2010, 5:23am

How it works

Well... as you can see.. there is alot going on here.. But I will try my best...

To start off.. on the server portion of it all.. I am using EasyPHP 5.3.0... really only for the apache web server portion of it tho.. server is running Win XP SP3. I have Jabaco and MSVB 6.0 Enterprise installed. The server still is not converted to Jabaco.. as that is a whole new can of worms I have not yet opened up for several reasons. The 'server' has 3GB ram, and 2x 2.00GHZ for processor.

Basically.. the client uses one of the 'commands' ... named .. CORD... to say to the server... Im at this xy position, on this frame, in this direction, my username is this... etc...

The server knows who you are.. and where your information is supposed to go... everybodys info is held in a user defined type.. and it looks like this:

In VB6/server:
Public Type UserTracking
MapNum As Integer
x As Integer
y As Integer
charType As Integer
charDir As Integer
charFrame As Integer
Username As String
lvlExp As Long
lvlMag As Long
lvlMoney As Integer
End Type
Public Userdata(0 To 500) As UserTracking

(Also, there is a winsock control.. that duplicates itself if enough sockets dont already exists.. named sckServer(), and Userdata(value) and sckServer(value) correspond to each other on server side, always.

When you log into the server.. it reads thats users copy/index of the user defined type [userdata(index)] from binary file from disk.. and saved when you disconnect or logout in the exact same manner.

On the client (in jabaco).. the same user defined type is declared.. and used.. also in an array... only.. 'yours' is always userdata(0).... everybody else's is sent from the server in the same CORD command.. its just verified first.. and throws each users index into the string before it actually sends it out to everybody else...

On the server:
CORD XX YY D CCC MMM III F NAME----> 'outgoing (to clients) format
CORD XX YY D CCC MMM F NAME----> 'incoming (from clients) format

On the client in jabaco:
CORD XX YY D CCC MMM III F NAME----> 'from server
CORD XX YY D CCC MMM F NAME----> 'to server

Whenever any of your values are changed, the client sends all the new values to the server to assure consistancy on all screens, its verified.. and resent to everybody connected.

The map drawing works in a similar manner..

MAPD command... which is sent to each client.. when you send same command 'MAPD <mapnumber_here>', only with one value to declare, what map # you want.

it sends back all the information about the map... as soon as it receives the first 'section' of this giant string.. the client knows to pause the animation loop (on timer1 i believe), then clear the map buffers and start over, then as each section of the map (individual tile information) is received, it draws it into the corresponding buffers, and when the last section of the big 'MAPD' string is received... it unpauses the animation loop.. and the new map is there..

Example to draw one tile (2 strings):

MAPD L2XS 10, 8 6|
MAPD L2YS 10, 8 4|

L2XS means .. draw it on Layer2 (walled objects)... its XS (xsource in the tileset), for position x10, y8 on the map.. eqauls 6

L2YS means .. draw it on Layer2 (walled objects)... its YS (ysource in the tileset), for position x10, y8 on the map.. eqauls 4

So.. at position 10,8 on the map... were going to draw a 32x32 pixel tile ..extracted from position 6,4 in the tileset... 10,8 would mean pixels 320,256 .. and its width and height are 32 pixels.

There are 4 layers, a background tile layer, which is the floor, and the floor tile layer holds two values, the x and y src in the tileset of what one single tile is the floor.

Layer 1, is objects that are on the floor..
Layer 2 is objects you or NPC's cant walk thru..
Layer 3 is translucent items the appear ontop of you..

Also I would like to note.. with the packets going back and forth./that current Const Delimeter = "|".. thats because a pipe (|) is what tells the client the whole packet has been received and is there, go ahead and process it, any new information thats received will go into the new packet... If you change this.. you must also change it on the server.

There is actually a limit of 450 sockets to be allow to be used.. this is because the last 50 index out of the defined 500 in userdata()... dont exist.. but instead refer to a similar user defined type for the NPC's.. 50 of them per server right now.. but the client sees NPC's as index 450 to 500 when using the CORD command... real users belong in 1 to 449.. 0 isnt used on the server.. because you always refer to yourself as 0 in the client.. AND the Winsock on the serverside.. [ sckServer(0) ] .. is always the listening socket.

I have used port 21 for the server so that when the client is ran as an applet, it thinks its connected to an FTP server and doesnt idle out (that i have noticed at least), and there is no need for ping ponging each other constantly or wasting bandwidth. Also.. port 21 and 80 (for serving) is not blocked by my ISP.. TW cable.. but all others seem to be.. =P

The VB6 server portion.. spits out a few .htm files that hold user data that is displayed when loading the applet from my website.. and the 'server console log' too.. and all of it is meshed together with another html file.. and some javascript was used to make those stat htm files reload every 15 seconds or so... the 'Logout' link also used javascript to close the window.

The reason I have not included the server, even as an executable yet.. is because i still have a few more things I want to do to it before releasing it... especially the source..

Eventually.. I want to sit down and comment the end of every line in both the server and the client.. but my time is limited right now, and hopefully I will get around to it here soon. ;)



I think the best way to start this is for anyone to ask they're question now and Ill do my best to explain any part of it I have missed (which is a lot, i know.. i kind of just dont know where to start to be honest).. ;)

Until later,
Jason

Aaron

Beginner

  • "Aaron" is male

Posts: 7

Date of registration: May 1st 2010

Location: Scotland/United Kingdom

Occupation: Student

Hobbies: Computer Programming

  • Send private message

5

Monday, May 3rd 2010, 5:36pm

Thats cool, thanks for explaining I get the general idea.
Regards -Aaron

"Intellectual growth should commence at birth and cease only at death."

Aaron

Beginner

  • "Aaron" is male

Posts: 7

Date of registration: May 1st 2010

Location: Scotland/United Kingdom

Occupation: Student

Hobbies: Computer Programming

  • Send private message

6

Saturday, May 15th 2010, 4:44pm

When Using the server and client, then registering it just goes black.
Regards -Aaron

"Intellectual growth should commence at birth and cease only at death."

jayess

Trainee

  • "jayess" is male
  • "jayess" started this thread

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

7

Saturday, May 15th 2010, 5:37pm

Black nothing when registering account on your own server

Okay.. gotcha.. just make sure that inside the folder your server executable sits in .. make sure there an empty is a folder (may be case sensitive not sure).. named Userdata ... i deleted mine in test server and caused the same issue...

~jason

Aaron

Beginner

  • "Aaron" is male

Posts: 7

Date of registration: May 1st 2010

Location: Scotland/United Kingdom

Occupation: Student

Hobbies: Computer Programming

  • Send private message

8

Tuesday, May 25th 2010, 6:45pm

Speed

It runs a bit slow, how about some preloading and caching?
Regards -Aaron

"Intellectual growth should commence at birth and cease only at death."

jayess

Trainee

  • "jayess" is male
  • "jayess" started this thread

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

9

Tuesday, May 25th 2010, 10:51pm

It actually used to be a lot slower than it is now... the only way I have found to make it run faster and smoother, is to increase the swap file size for java itself.. that made a huge difference.. unfortunately.. there doesn't seem to be a way to change this via Jabaco (run-time) yet at least.. trust me i have looked into it =P

JasonS

Trainee

  • "JasonS" is male
  • "JasonS" started this thread

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

10

Tuesday, September 20th 2011, 6:53am

I have emptied out a few previous replies from myself on this thread to better reflect accuracy on this project of mine. 8)

I recently made some changes to this project.

Added bomb dropping, and other users can now see when you drop them, bombs belong to maps theyre dropped on, etc.

I added server controlled weather effects (rain, snow, and clear sky). I will turn on snow around december ;)

Basically the server daemon now has 5 settings for weather which has to be set on one, default is 0:
'0 = Raining off and on
'1 = Raining Steady
'2 = Clear Skies
'3 = Snowing Off and on
'4 = Snowing Steady

This has been an extremely fun project to see come together in applet form I must admit.

I have had one major issue I have spent hours trying to remedy but with no luck.

I have several timers working their thing, and a winsock control.. and the way the applet is closed is by closing the window or clicking the logout javascript hyperlink, which essentially does the same thing. I cant seem to find a way to trap in the code when this has happened, so that i can stop the timers and close the winsock control before the applet is destroyed, resulting in a grouping of exception errors when you close out the game applet. I have tried many different things, and even putting a button on the applet to end it results in 'access denied' using system.exit .. I have tried simple tests with a blank form that does nothing and things like Applet_Destroy, Applet_Unload do not get called when the applet window is simply closed... I have even tried setting a timer to listen on the value of AppletViewer.isActive, AppletViewer.isDisplayable , etc.. nothing. This works in jabaco run time, but not when running in a web browser :(

Cheers,
Jason

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

11

Wednesday, October 26th 2011, 5:18pm

Two points in relationship to your code:

1. If you want to publish complete sourcecode of a project, then you can add a compressed file (like a *.zip file) with the *.jba and *.jsrc files as attachment here in the forum.
For examples your code is too much. And for publishing a complete project, it have to less informations.
Jabaco files are XML-files. The text you input is only one part of it. Informations like the name of the Superclass, the Class-name itself and so on is only in the complete XML-files.

2. Is it because you have copied and pasted your code in the forum or do you really write your code unformatted?
If the last is true, then I suggest you, to format your code for yourself (for later reading) and for other people.

For example your Subroutine picFinal3_MouseMove. Here how you have posted it here:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Public Sub picFinal3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 1 And Shift = 1 Then
lnMsX = X
lnMsY = Y
Elseif Button = 2 And Shift = 0 Then
If booShowDust = True Then
booShowDust = False
Elseif booShowDust = False Then
booShowDust = True
End If

If booShowDust = True Then
PlayClip 27
End If
Elseif Button = 2 And Shift = 1 Then
lnMsX2 = X
lnMsY2 = Y
If booShowDust2 = True Then
booShowDust2 = False
Elseif booShowDust2 = False Then
booShowDust2 = True
End If

If booShowDust2 = True Then
PlayClip 26
End If
End If
End Sub


And this way it looks like, if you formatting the code:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Public Sub picFinal3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

  If Button = 1 And Shift = 1 Then
    lnMsX = X
    lnMsY = Y
  Elseif Button = 2 And Shift = 0 Then
    If booShowDust = True Then
      booShowDust = False
    Elseif booShowDust = False Then
      booShowDust = True
    End If

    If booShowDust = True Then
      PlayClip 27
    End If
  Elseif Button = 2 And Shift = 1 Then
    lnMsX2 = X
    lnMsY2 = Y
    If booShowDust2 = True Then
      booShowDust2 = False
    Elseif booShowDust2 = False Then
      booShowDust2 = True
    End If

    If booShowDust2 = True Then
      PlayClip 26
    End If
  End If
End Sub


Greatings
theuserbl

JasonS

Trainee

  • "JasonS" is male
  • "JasonS" started this thread

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

12

Wednesday, October 26th 2011, 6:20pm

Well, Okay.

#1) I cannot upload a zip file of the complete zip file of the jabaco project due to a file size limitation of the board
#2) I DO format my code correctly, come on
#3) When I paste in my code from Jabaco to firefox, it looses its indention's. Why? I have no clue. The same seems to happen with IE.

JasonS

Trainee

  • "JasonS" is male
  • "JasonS" started this thread

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

13

Wednesday, October 26th 2011, 6:33pm

Client Source

I guess the only option is to host the client source zip file..

It is located here: http://www.tecktronic.net/jrpgt/jrpgt_client_src.zip

This post has been edited 2 times, last edit by "JasonS" (Dec 4th 2011, 5:07pm)


theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

14

Wednesday, October 26th 2011, 6:37pm

#1) I cannot upload a zip file of the complete zip file of the jabaco project due to a file size limitation of the board


Possibly it helps to split the file?
One possibility could be to create one file with the sources and one file with the graphics.
Your sourcecode as compressed file could never be too big for the forum. The problem could only be the graphics.

An additional possibility to upload it, could be the use of SPLIT.EXE:
[ http://www.martinvogel.de/prog/split.html ]

Or if you want to make your project OpenSource, you have the possibility to create a project on GoogleCode and upload your files there:
[ http://code.google.com/hosting/ ]
The Jabaco Framework is hosted on Google Code, too, btw.:
[ http://code.google.com/p/jabacoframework/ ]

But I don't said, that you have to delete all you posts with your sourcecode.
Now the forum have a lot of deleted posts in this thread.


Quoted

#2) I DO format my code correctly, come on
#3) When I paste in my code from Jabaco to firefox, it looses its indention's. Why? I have no clue. The same seems to happen with IE.


Hmmm.... Do you have JavaScript enabled?
I have. And I have posted the formatted form from an Linux system. Don't know if this is the reason, why I can post formatted code here and you not.


Edit:

Quoted


Ok, this is a solution, too.



Greatings
theuserbl

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

15

Wednesday, October 26th 2011, 10:57pm

Hmmm.. dont find the bug.

On Windows XP your program runs fine. But on Linux it don't work.
If I start your program at your side in the browser, there comes always this error:

Source code

1
2
3
4
5
6
7
java.lang.NullPointerException
  at VB.PictureBox.PaintPicture(PictureBox.jsrc)
  at Applet1.Timer3_Timer(Applet1.jsrc:1758)
  at Applet1$Timer._Timer(Applet1.jscr:1985)
  at VB.Timer.actionPerformed(Timer.jsrc)
  at javax.swing.Timer.fireActionPerformed(Timer.java:313)
  [... etc.]


This is, when I start in the the browser. I have compiled your sources and tried to run it with the Java command from the console. The intro-screen works well, but in the game I see only a black field. No graphics. Don't know why. I see no error in the code.

At line 1758 from Applet1.jsrc there is

Jabaco Source

1
2
3
4
Public Sub Winsock1_Connect()
   Doevents
   Timer4.Enabled = False
End Sub


Possible, that Winsock only exists for Windows. Like the WinAPI function, which Jabaco have.

Greatings
theuserbl

JasonS

Trainee

  • "JasonS" is male
  • "JasonS" started this thread

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

16

Wednesday, October 26th 2011, 11:03pm

Winsock on Linux in applet

Hmm.. that is weird... it used to work on Linux/Mac..

Try http://www.tecktronic.net/draw and see if that will work at all for you, this also has been tested on Linux previously and worked.

Thanks much :)

-Jason

This post has been edited 1 times, last edit by "JasonS" (Nov 16th 2011, 3:58am)


theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

17

Wednesday, October 26th 2011, 11:34pm

Yes, the drawing program works on Linux. Is there Winsock used, too?

Seems, that the picture is there saved on an server. Because when I reload the Applet, the created picture is reloaded.

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

18

Wednesday, October 26th 2011, 11:40pm

It worked and gives now out Error-Messages:

Source code

1
2
3
4
5
6
7
java.lang.NullPointerException
  at VB.PictureBox.getGraphics(PictureBox.jsrc)
  at VB.PictureBox.$Image(PictureBox.jsrc)
  at Applet1.RecData(Applet1.jsrc:122)
  at Applet1.Winsock1_DataArrival(Applet1.jsrc:68)
  at Applet1$Winsock._DataArrival(Applet1.jsrc:201)
  [... etc]   


In Firefox 64bit on OpenSuSE 11.4.
"about:plugins" gives for Java out:

Source code

1
Java(TM) Plug-in 1.6.0_21


Edit: The Error messages comes, but the applet still works.


Greatings
theuserbl

JasonS

Trainee

  • "JasonS" is male
  • "JasonS" started this thread

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

19

Thursday, October 27th 2011, 12:16am

I have fixed the issue where it wouldn't login when running client on MacOS or Linux... it was a ascii character value issue on the 'welcome/ready' string. I have added in the bottom left corner of the applet a green label, that contains numbers, if the client crashes, you can search for that number, and you will know what section the error in the code is in while its still running--this allows to trap the location of a 'problem' when there is not an exception dialog.

Yeah, the drawboard does use winsock and data is stored on the same server as JRPGT, different daemon though. I always get the errors when closing the applet's too even on different browsers and different OS. It has something to do with not being able sense that the winsock control(s) need closed and timers need disabled when the applet is closed by closing the browser or tab. I have in return tried to add 'Exit' buttons on the applets, and the system.exit etc return Access Denied exceptions...

I wish I knew of a way via javascript in the html file, to send a trigger to the applet... anybody know how to do this? :)

As far as the exceptions/errors on applet close, it only happens in browser, not when executing project from Jabaco.

Thanks for your help!

-Jason

This post has been edited 3 times, last edit by "JasonS" (Oct 27th 2011, 5:54am)


JasonS

Trainee

  • "JasonS" is male
  • "JasonS" started this thread

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

20

Thursday, October 27th 2011, 11:06pm

I have trapped and corrected a couple more bugs:

When using samples obtained from this board for Functions GetWavResClip and LoadResData, I changed:

Jabaco Source

1
2
3
4
5
6
7
8
9
Public Function GetWavResClip(ResID As IResource) As Clip
   GetWavResClip = AudioSystem.getClip
   GetWavResClip.open(AudioSystem.getAudioInputStream(LoadResData(ResID)))
End Function


Public Function LoadResData(resID As IResource) As InputStream
   Set LoadResData = getClass.getResourceAsStream(resID)
End Function


to the following:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
Public Function LoadResData(resID As IResource) As InputStream
   Set LoadResData = Nothing
   Set LoadResData = getClass.getResourceAsStream(resID)
End Function

Public Function GetWavResClip(ResID As IResource) As Clip
   Set GetWavResClip = Nothing
   GetWavResClip = AudioSystem.getClip
   GetWavResClip.open(AudioSystem.getAudioInputStream(LoadResData(ResID)))
End Function


After the client being loaded for approximetly 1 hour, I would start getting exceptions continously in reference to "Out of memory, java heap space", so I trapped and added the line to empty the variable in LoadResData, then found I needed to empty the same way before loading in GetWavResClip, after getting repeated exception "Unable to create native thread", this error after corrected has ceases to exist.

I have update the sourcecode zip file, and online applets on jrpgt.tecktronic.net.

Reguards,
Jason

Rate this thread
WoltLab Burning Board