Welcome, Guest. Please login or register.

Author Topic: Looking for advice on which web language to use  (Read 9540 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Looking for advice on which web language to use
« on: February 23, 2008, 11:15:16 AM »
I'm once again thinking about writing a web-based space trading/combat game (I don't like to say a web-based version of Eve as that's a big job, but that's what it would be modelled on). I did make some progress with this the last time I started, with a database structure to contain regions of space containing solar systems, which in turn contained planets. There was a hyperspace system to jump from one region to the next, and you could fly from one planet to the next, land on planets, buy and sell goods , refuel, send/received messages to/from other players. It was quite good!

The game was written in PHP, with the frontend being basic HTML - nothing fancy as I want the game to be accessible from as many devices and browsers as possible. Unfortunately, PHP was also the downfall of the game. Because it only updated when the page refreshed, I could find no way to notify the user of new messages unless they did something which refreshed the page. Also I couldn't think of any way of implementing combat in real time if the page doesn't update automatically. It would also be difficult to implement things like being intercepted during travel.

So I'm hoping there is a language out there which can do what I want. I need the backend to be able to force the web page to refresh in case something happens in the background (user gets contacted/attacked/whatever, or a move is made during combat). But the frontend should still be basically plain HTML to make sure it works in any browser.

Is there any way to accomplish what I want?

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Speelgoedmannetje

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 9656
    • Show only replies by Speelgoedmannetje
Re: Looking for advice on which web language to use
« Reply #1 on: February 23, 2008, 11:45:16 AM »
Java. (as applet)
And the canary said: \'chirp\'
 

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Looking for advice on which web language to use
« Reply #2 on: February 23, 2008, 12:42:12 PM »
Quote

Speelgoedmannetje wrote:
Java. (as applet)


I don't think Java would be good for this... I would read up on HTML5. ECMAScript is your friend :-)

Offline Speelgoedmannetje

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 9656
    • Show only replies by Speelgoedmannetje
Re: Looking for advice on which web language to use
« Reply #3 on: February 23, 2008, 12:55:39 PM »
:lol:
And the canary said: \'chirp\'
 

Offline motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Looking for advice on which web language to use
« Reply #4 on: February 23, 2008, 01:00:56 PM »
I'm not sure I want to use Java as it will limit the devices which will be able to use it. How easy is Java to learn? I've got some experience writing games in C++ so if the syntax is similar I will consider it.

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Speelgoedmannetje

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 9656
    • Show only replies by Speelgoedmannetje
Re: Looking for advice on which web language to use
« Reply #5 on: February 23, 2008, 01:04:53 PM »
It's quite similar.
But you don't have to use pointers as much.
And the canary said: \'chirp\'
 

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Looking for advice on which web language to use
« Reply #6 on: February 23, 2008, 01:15:26 PM »
Quote

motorollin wrote:
I'm not sure I want to use Java as it will limit the devices which will be able to use it. How easy is Java to learn? I've got some experience writing games in C++ so if the syntax is similar I will consider it.

--
moto


Both Java and ECMAScript (or whatever you want to called it) are modeled on C++ (though a three use slightly different OOP paradigms)... So knowing any of them will allow easy working with the others.

As Speel knows, I'm rather keen on ECMAScript since every modern browser can run it... You can prototype quickly and it's very fault tollerant... The only thing I don't like is the Document Object Model, but once you learned it it's fine!

Offline Speelgoedmannetje

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 9656
    • Show only replies by Speelgoedmannetje
Re: Looking for advice on which web language to use
« Reply #7 on: February 23, 2008, 01:24:58 PM »
You cannot use classes in ECMAScript like you can use them in Java. And it certainly does not have as much libraries as Java. And it's just plain messy.
And the canary said: \'chirp\'
 

Offline motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Looking for advice on which web language to use
« Reply #8 on: February 23, 2008, 01:46:12 PM »
If I use ECMAScript/JavaScript, how can the backend tell the frontend that something is happening of which the user needs to be made aware? I thought JavaScript could interact only with elements on the page, not with anything external like a database.

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Speelgoedmannetje

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 9656
    • Show only replies by Speelgoedmannetje
Re: Looking for advice on which web language to use
« Reply #9 on: February 23, 2008, 01:53:35 PM »
Maybe in combination with CGI.
But really, JavaScript is a nightmare which I want to forget ASAP.
And the canary said: \'chirp\'
 

Offline motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Looking for advice on which web language to use
« Reply #10 on: February 23, 2008, 02:21:34 PM »
Javascript and CGI will leave me in pretty much the same situation as PHP. Yes CGI/PHP can obtain information from the database about where the player is and their status, but this will only occur when the page loads and the script runs. There is no way I know of for the server to say "user with this session ID: something has just changed, force the page to refresh". The only workaround I can think of is to have a frame continually refreshing and running a script to check for these things and then refresh the main window if anything changes. But this is messy and inefficient, is likely to lead to the focus being stolen while the user is doing something, will cause massive strain on the database, and will not be ideal during real-time combat.

I'm starting to think Java is the only alternative, but I was really hoping to keep this as simple as possible so that it will run on pretty much any browser.

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Looking for advice on which web language to use
« Reply #11 on: February 23, 2008, 02:33:05 PM »
Yeah, I would use a hidden iframe with a 10 sec refresh to sync the database... It you take the java route, to be honest you would be better off using C and SDL... Then compile a native version of the client for each target platform... Yes, I really don't like java :-)

Offline motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Looking for advice on which web language to use
« Reply #12 on: February 23, 2008, 02:41:48 PM »
I would prefer not to have to learn a new language. But at least a Java applet can run in a browser, meaning players can connect from any machine with a Java capable browser. I'm just trying to make the software as flexible as possible, so it's accessible from pretty much anywhere.

The advantage of sticking with PHP is that it is really, really easy to interface to the back-end using PHP's MySQL interface. I have no idea how "real" online games work - presumably they don't just read values from a database to get status and update/insert rows to update the database with any changes? I would guess they have some kind of direct connection to proprietary software on the server, but I would have no idea how to start with coding something like that.

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Speelgoedmannetje

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 9656
    • Show only replies by Speelgoedmannetje
Re: Looking for advice on which web language to use
« Reply #13 on: February 23, 2008, 02:58:00 PM »
Quote

motorollin wrote:
but I would have no idea how to start with coding something like that.
I guess you know how to program object oriented? And you have learned about software design patterns? When you can you know it won't be much of a problem :-)
And the canary said: \'chirp\'
 

Offline motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Looking for advice on which web language to use
« Reply #14 on: February 23, 2008, 03:06:26 PM »
Quote
Speelgoedmannetje wrote:
I guess you know how to program object oriented?

Yes. When I wrote my GP2X GridWars clone that was all object oriented (C++).

Quote
Speelgoedmannetje wrote:
And you have learned about software design patterns?

I know what they are, but I have never used one. I don't like the idea of trying to make my game fit in to a template.

Quote
Speelgoedmannetje wrote:
When you can you know it won't be much of a problem :-)

Depends on whether I can understand the pattern :lol:

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10