Welcome, Guest. Please login or register.

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

Description:

0 Members and 1 Guest are viewing this topic.

Offline motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #1 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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #2 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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #3 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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #4 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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #5 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
 

Offline motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #6 on: February 23, 2008, 04:31:13 PM »
OIC. I would be interested to see how an online game communicates with the back-end and keeps synchronised. Any ideas when I can get information on design patterns for things like this?

--
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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #7 on: February 23, 2008, 04:35:53 PM »
Hmm, I wonder if this would be any better than JavaScript:

http://en.wikipedia.org/wiki/AJAX

"A primary characteristic is the increased responsiveness and interactivity of web pages achieved by exchanging small amounts of data with the server "behind the scenes" so that entire web pages do not have to be reloaded each time there is a need to fetch data from the server."

--
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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #8 on: February 23, 2008, 05:27:15 PM »
Quote
Speelgoedmannetje wrote:
I'd use (and have used) a threaded method in combination with observer/observable implementation.

It's really the establishment of a connection between the client and the server and exchanging information between them which I am unsure about.

--
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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #9 on: February 23, 2008, 05:48:10 PM »
Quote
bloodline wrote:
Anyway, don't you have some music homework to be doing? ;-)

Yes sir.... ;-)
Though if I'm honest, I'm a bit demotivated in that area at the moment :-(

--
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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #10 on: February 23, 2008, 06:33:35 PM »
That's a good quote - so true! The problem is that your advice and suggestions have given me a lot to live up to! And unfortunately when I know something is going to be difficult or beyond my (current) abilities, I tend to lose motivation and give up prematurely. I've always been an underachiever... :roll:

--
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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #11 on: February 24, 2008, 08:17:03 AM »
Quote
bloodline wrote:
I can assure you, there is nothing that I have suggested which is beyond your abilities...

Hmm, ok if you say so :-)

Quote
bloodline wrote:
you just need to devote some time to it. Set aside an hour tomorrow with your keyboard and sequencer and have a bit of a play... even if your first efforts sound a bit forced, that's good because you know you are doing it right, then you just need to develop that! :-)

I actually have something in mind for a synth bass part, including the instrument. But you said it's best not to focus on sounds yet. Am I allowed to make an exception in this case? :-) And if I do my music homework, can I play with AJAX please? ;-)

--
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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #12 on: February 24, 2008, 11:05:52 AM »
BTW, is this an acceptable login/session management solution in PHP?

1. Username and password submitted to login script
2. Username and password checked against details in users table
3. Username and password match a user account
4. UserID retrieved from account
5. session_start();
6. Username and UserID stored in variables in $_SESSION[];
7. At the top of each page, session_start() is called

Is that secure enough?

--
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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #13 on: February 24, 2008, 11:07:10 AM »
Quote
bloodline wrote:
There are no hard and fast rules, anything that keeps you motivated is obviously a good thing.

Oh go on, give me some hard and fast rules :lol: Ok, I'll try to dedicate some time to this again, probably tomorrow now since a visit to the in-laws is dragging on.... zzzzzzzzz......

--
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 motorollinTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show all replies
Re: Looking for advice on which web language to use
« Reply #14 on: February 24, 2008, 11:48:39 AM »
Quote
Speelgoedmannetje wrote:
Make sure you store a password hash in the database, not the password itself.

Yes, the password is stored as md5. The login script then does $password=md5($password) before checking against the Users table.

Quote
Speelgoedmannetje wrote:
Also, make sure no SQL injection is possible.

Hmm, just done some reading about this. Sounds scary! Can I guard against this by processing all user input with addslashes()?

--
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