Learning another language
Miscellaneous Forums/General Discussion/Learning another language
Sorry if this seems a bit off-topic for a Blitz forum, but I'm having no joy on other forums.
I recently wrote an online game using Blitz, but it hasn't worked out for a variety of reasons and I'm thinking that I'd be wise to start from scratch. The biggest problem, in my opinion, is that my game was downloadable (and also too complicated). I'm thinking that I'd like to learn how to program games in webpages, but I don't think Blitz is the language for that.
What I'd like to learn is how to write a multiplayer game that runs directly in a browser. I'd prefer to use Visual Basic because I know the language and it's very easy to use, but I'm aware that I'll need to learn some other stuff. The client browser is fairly easy, but I'm not sure how I'd go about storing the information for the players. Presumably I'd need to learn some database skills. And I'd need a program running all the 'logic' to the game - how would the client browser talk to the 'server'?
As I say, I know this isn't Blitz related but alot of you guys have experience of other languages and at least I get answers on these forums :) Any help pointing me in the right direction would be appreciated :)
I think you've got a couple of options there, but Visual Basic - unless you use it to program against SilverLight - isn't one of them.
I'd use Flash for the browser/client side. Then you -could- use Flash Remoting for the server communication. On the server you could use any language and platform that supports Flash remoting (Python, Java, .NET, PHP, ColdFusion, whatever else).
Or you program the client in Flash/ActionScript and handle the communication to the server via (XML)Sockets. Again, the server could be written in almost anything (including BlitzMax).
As said above, maybe Microsoft's SilverLight or Mono's MoonLight could also be options for you; you should be able to use Visual Basic.NET with them. But Flash is everywhere, so -- I -- would not go there. But since you like VB, it might be a great option for -- you --.
Then there's the option of writing a Java Applet -- or -- using Java Web Start. But that requires a Java VM on the client computer.
Of course, you could also buy Unity - they have a browser plug in, don't they? ;-)
I don't know how far JavaScript could get you for your purposes.
As you see, as always there's no 'right' answer.
Do yourself a favour and forget Visual Basic for games development.
I should've pointed out that initially I planned to write a VERY simple game using just text. But you're right - there's not much point learning a language if it's going to be limited in the future. I'll have a fiddle around with Flash, see where that gets me :)
On second thoughts... I may not know what I'm talking about. It was a long time ago that I looked at VB for games dev. I think Java is worth a look. It's probably a bit more versatile than Flash.
Java/Flash:
Java might be more versatile than ActionScript (Flash), but it's also a lot more complex, and it comes with a deployment problem: It's a safer bet to assume that a Flash Player is installed on a computer than a Java VM (unless you aim only at Macs, where a Java VM comes with the OS).
You also cannot assume that a Java app that runs on a Java 1.4 VM will also run hassle-free on a Java 1.5 or 1.6 VM. Just look at that complete disaster that Netbeans 6.1 is on Apple's Java 6 VM, for example; it won't even react to keyboard input. The game Tribal Trouble does not even run on Apple's Java 6 VM (but it runs nicely on Apple's 64-Bit Java 5 VM).
So in real life, Java is "write once, debug everywhere" rather than "write once, run anywhere."
Visual Basic:
The current versions of VB.NET come close to the features of C#.NET; you'll get the same power and complexity. The Open Source IDE SharpDevelop actually translates VB to C# or vice-versa, if you want/need it.
The beauty of the .NET platform is that the language does not really matter anymore; you could also use IronPython instead of VB or C#. Okay, you could also use Jython on the Java platform - and that is the beauty of Python. ;-)
..get Unity and ride on all platforms..or better say pretty much all..
ASP .net (supports Visual Basic or C#) / PHP with an SQL database will do for a simple browser based game with text very easily. It won't be a real time interface for the user though, it will be the user is presented with a page with options, selects his choices, and then submits this to the server. The server langauge (ASP/PHP) processes these choices, and updates that database (keeps track of the current world 'state') and then generates a new page for the user.
Like this game
http://www.astroempires.com/ (<= ASP)
Depends on what your goals are. If you absolutely want everyone to be able to play your game with a standard browser, use JavaScript for the client side, since there's hardly a browser that does not support JS these days. Then you would use XML requests to interface with the server (which could be written in any language).
If its ok that some users won't be able to play (at least without a plugin hassle), you could use Java or Flash. Silverlight still has a long way to go, but may well be the best platform in the future.
Thanks for all the input guys, it's very much appreciated. I'm one of those people who's done alot of 'old skool' programming but have shied away from this newer stuff, simply because I don't like it.
But I've had a look through loads of tutorials last night and JavaScript looks very easy - it's basically HTML (which I've used a lot anyway) and a simple BASIC language and I followed the tutorials very easily. It certainly looks capable of building the kind of simple browser that I'm contemplating for my text-based game.
The only bit I'm still confused about is the server and how to communicate with it. I started looking at XML and that looks like the right way to go. I'll try the tutorials on that tonight.
I assume I'm right in saying that I could run the server in the same way that I did my Blitz server/client - i.e have the computer set up in my house and all connections come directly here? I was under the impression that modern servers need to be stored on a host somewhere - not sure why I was thinking that.
And when you say I could use any language for the server, would that include Blitz3d? That would be very handy if it does, because I know B3D like the back of my hand and would mean much less learning to get started.
for server side i would recommend Bmax..
XML is a solution to a problem that you don't have; it's a semantic to describe data and it's main purpose is to exchange data between otherwise incompatible systems. Since you don't do that, using XML in your case would only add complexity -and- a performance overhead. Just because all the Java heads automatically fall back to using XML and just because everybody in the industry does not even think about it anymore does not mean that it's always right. But I don't know what sort of options you have in JavaScript since I don't use it (only Flash/ActionScript).
From what you are describing, I get the impression that you could simply use querystrings in your URL calls from the client, which would submit data to the web server.
If you go down that route, there's no need to write something like a socket server yourself -- CGI and Brucey's ClearSilver module for BlitzMax would be your friends here.
Or PHP. (Or Python. Or Ruby.)
You can host a low traffic server in your own house -- check out the DynDNS service, it will help you solve the issues with dynamic IP addresses (www.dyndns.org).
What language are you using on the server, I'm getting confused. Javascript is a client side language, it does fancy stuff on your browser, but it won't run anything on your server. If this is a browser-based game you should use either ASP .net or PHP. Personally I prefere ASP .net because I think the development tools are better, but you will find fanatics on either side.
If this is not a browser game, then Javascript and the like will be useless to you.
So I think you need to decide, browser or non-browser.
Definately a browser game, like the one you suggested above
http://www.astroempires.com/ (<= ASP)
That's obviously a bit complex for a newbie, but it's the sort of thing I want to be aiming towards.
I'd be quite happy using vb.net, could I therefore write the server in Blitz and the client in vb.net (or ASP, I've done a bit of that). And how would they communicate with each other?
Taking the example of astroempires above, the client is written in ASP, would the server be stored on a PC somewhere and how are they communicating?
You're getting client/server mixed up. ASP is a server-side language only, you cannot write a client in it. In the case of a browser game like the one I showed you, the client is the player's browser and the HTML page displayed in it, with Javascript (a client-side language) to spice it up. Once the server has sent the new page to the player, ASP cannot have any futher control over what happens until the user submits the page back again.
If you are going to follow this model of game, I'm afraid Blitz doesn't fit anywhere into the picture - Javascript/ASP.net already covers the full works, with unlimited support and help online, and tried and tested features. Forcing Blitz into this particular scenorio will just cause more problems than it solves.
A simlpe example of a game like this. The server keeps a database of account information, including username, password, charecter stats and location. The user logs in and the server creates a HTML page using ASP to tell the user about his current location and provide him with a list of buttons, such as to move location, or to attack another player in the room.
How does this happen? The ASP server recieves the login data, and performs an SQL query on the database to find the details of the current room the player is in, such as a text description pseudo code : executesql("SELECT RoomDescription FROM Room WHERE RoomID = " + player.id);
More comlpicatedly you can also get the list of rooms linked to this room to generate the movement buttons and the list of players to create a 'tailor-made' HTML page for the player. But the important thing is, once the player gets this HTML page, the ASP stops (for him).
The player then clicks a button which submits the page, and the server gets back the details of the user, and the chosen action. By looking up and editing the database you can now move the player or perform other actions at the server-side level. Whilst this is happening (split-second) the user's browser is idle waiting for a reply. When the server has updated the database it will probably peform the exact code above to giev the status screen and options back to the player - but of course this page will be different from the first, to take into account these new changes.
An example of the use of Javascript could be thus: by default only a list of player names is displayed and their level, but these are hyperlinks that, when clicked, execute Javascript code to update a statistics box on the page with the player's detailed stats, avoiding drowning the player in too much info at once. The important thing is this happens soley on the player's computer - the server has no knowledge this happend at all. Javascript didn't spontaniously request this data from the server, it was already there, just hidden data in the browser's page.
Without Javascript (or alternatively with Javascript if you wish, using Javascript to cause the page to submit itself) the player would have no choice but to submit to the server the intention of getting these stats, and waiting for the page to reload from the server with the new information. But this will play awkwardly.
The key point is that it is an all-or-nothing affair. There is no "real-time", so to speak, updating and communication of data. Sure the game can be processed and updated real-time on the server, but without refreshing the page the user won't learn of any new occurances. It's player get page with info, submit new action, get new page with new info and actions. This sounds rather limiting but it's actually qutie easy to create "worth-while" games using this system, but if you are looking for a game that is specifically real-time, or action-orientated (rather than think-and-submit), it may not be best for you.
You can think of it like Chess. The other player waits for you to submit a move, then springs into action, shows you his move, then lies in wait. But he may be updating other games of Chess you don't know about...
There hasn't been any good language since C.
C++ is only good when used cauciously and not object oriented.
The goal of every language should be to create the fastest possible code,
and not to support lazy and erraneous people.
Assembler would be the optimal language, if there wasn't C which produces optimized assembler code, and almost everytime beats the speed of manually entered assembler code.
BlitzMax is a nice drafting language though, it allows fast coding, but the code speed is accordingly slow compared to optimized C.
I can't think of any easier language than Blitz3D or BlitzMax either which produce at least somewhat fast code which is good enough for developing and testing games.
Ahh, thanks very much, that's explained many things. For my initial test-game, this probably won't work then, although for my main aim (updating my current game to a browser game), this would work because it's not real-time and the server only needs to respond to client actions.
Out of interest, is it not possible to have a timer in a Javascript page, so that it automatically asks for updates every 10 seconds or 10 minutes or whatever? So that you could create a sort of turn-based game?
You may also be interested in JavaScript based technologies such as AJAX, which build frameworks on top of JavaScript, XML/JSON, and servers to provide a much richer user experience. They tend to come with lots of aids so that you don't have to reinvent the wheel every time.
Things like pseudo server push (where it appears that the server is updating your "page" by itself).
A couple of examples of AJAX in action include gmail and google maps.
Anyhoo... just something else to think about :-)
You would rather use Visual Basic ,C++ ,C ,C#,and i thought this was Blitz Basic ,.Oi johnathan is that spike sharpe enought.
The goal of every language should be to create the fastest possible code,
and not to support lazy and erraneous people...BlitzMax is a nice drafting language though, it allows fast coding, but the code speed is accordingly slow compared to optimized C.
Given how many successful games have been scripted on top of middle-ware, I can't really say I'm with you -- valuing expedience isn't laziness! Besides, every half-decent language aims to deliver the fastest code it can
given its chosen level of abstraction, the provision of that particular level of abstraction being more of an overriding goal. (I mean think about it -- the goal of Assembler is no more to be fast than the goal of BASIC is to be slow;
Your goal in using Assembler, on the other hand, may well be speed.)
But anyway, I can't help thinking that anyone who opts for C and/or asm over an abstracted RAD solution solely for a bit of speed
when computers are getting faster all the time anyway has to be a masochist. It's just a manifestation of 'Not Built Here' syndrome, isn't it?
There hasn't been any good language since C.
Oh, there has... Pascal is as powerful as C, but easier to program in. And it even has a real string datatype, imagine that!
Today, I've spent a couple of hours with Python, and I must confess that I like it more and more. It's elegant, powerful and beats the shit out of any other language that I know in terms of productivity.
The goal of every language should be to create the fastest possible code,
and not to support lazy and erraneous people.
In a time where CPU power is cheap and man power expensive, this demand does not really make sense anymore. If you need something to run faster, you throw hardware at it -- not additional programmer hours to optimize some mysterious source code. Nobody is paying for that.
The simple reality is that while C or C++ programmers are still debugging their memory leaks and buffer overflows, almost anybody else who has used a different language is already shipping their products.
Whats the advantage of learning C++ over Blitz?
And is DirectX a worthwhile edition to C++?
And what is one of the best languages for Networking?
The Inquisitive WERDNA(Currently Learning C++ and DirectX)
Plain C is a useful string to your bow, I think. Personally, I wouldn't touch C++ with a barge-pole unless you aspire to a job coding game engines in the industry. Anyway, back on topic....
Werdna, define 'best language for networking'. My personal recommendations would be Python and Java - and in that order. Python's simplicity and productivity outweigh any disadvantages that it might have compared to Java.
Both languages support multi-threading, although that is not even a real argument for networking applications: You can write heavy load servers using a single process/single thread model. In Java before 1.4 multi-threading capabilities were vital, because you --had-- to use multiple threads to handle multiple connections. Older Java versions only supported blocking I/O and only with Java 1.4 users finally got java.nio (where the 'n' stands for 'new', but it could also mean 'non-blocking').
The advantages of C++? It's a much better choice for everything when you have masochistic tendencies. If you just want to get a job done, run away from it as fast as you can and use a productive language.
If you see yourself writing that next generation 3D game engine, C++ probably will be your language of choice (and on Windows, you also --have-- to look at DirectX). If you have more 'mundane' needs or career perspectives, using C++ is a waste of your life time: Corporate IT is developed in Java, COBOL and even SmallTalk (Deutsche Bank, Deutscher Herold, for example). On Windows, C++ has become a maintenance/legacy language that is mostly only being used in already existing code bases; .NET languages like VB or C# have become the languages of choice for new projects. Depending on the country, there is already more demand for C# programmers than for Java developers.
It never hurts to at least have a basic understanding of a system language like C or C++. But you're the only one who can answer the question whether that is where you see yourself in your future and whether that is the place where you will be happy.
Farflame,
look here - www.unity3d.com and get a c# or javascript book.
IPete2.
Out of interest, is it not possible to have a timer in a Javascript page, so that it automatically asks for updates every 10 seconds or 10 minutes or whatever? So that you could create a sort of turn-based game?
I believe you can use Javascript to do that, but you must remember that Javascript is unreliable. It usually works but your game's stability mustn't rely upon Javascript. For example, the user may have Javascript disabled, and you can't rely upon the Javascript to submit the page on time. But for an automated refresh every few seconds (where if this doesn't happen it won't break the game) would be perfectly fine. I suggest you give the user some options over this.
Personally I have no experience with AJAX or what it can do so I've not suggested anything to do with this, but I think it's worth looking into.
There hasn't been any good language since C.
C++ is only good when used cauciously and not object oriented.
The goal of every language should be to create the fastest possible code,
and not to support lazy and erraneous people.
Whether this is good advice or not aside, what relevence does this have?
I think I'm having one of those problems where it just needs to 'click' in my head. I can write an ASP webpage and I understand what's going on - the user clicks something, the ASP program calculates a response and sends a new webpage to the client. That part seems simple enough and it's as easy to build an ASP program as any other VB program.
The part I still don't understand is, where would I store information, such as character names, positions etc? Is this where I need to learn SQL? How does that SQL database information get updated? Does the ASP program update the database aswell as retrieve information from it? In other words, is my ASP program not only acting as the main program (in terms of 'running' the game), but also acting as a server which sends updated webpages?
ASP(.NET) applications --always-- run on the server and they represent server-side logic. An ASP.NET app will also communicate with the database server - via SQL or the new buzzword 'LINQ' - and retrieve and update information. So yes, your ASP.NET 'acts as a server which sends updated webpages'.
Session settings and data, however, would be stored in cookies on the client side; .NET has classes for session management.
You should be aware that you are now entering expensive ground. Microsoft's EULA does not allow use Windows XP or Vista as a 'real' web server (for unlimited users). To make this legal, you'd need a Windows Server 2003 Web Edition or higher. You should also check the legal side for the SQL Server - better ask Microsoft if you can legally use the MSDE 2000 or SQL Server 2005 Express Edition on a web server. Their license models are complex and it all depends on what you are actually doing with the database (and web) server. Depending on your needs, a good alternative for .NET applications is VistaDB. It's not free, but great for C# (or VB.NET) development and offers royalty free deployment.
To get it all for free AND legal, you could use GNU/Linux, FreeBSD or OpenSolaris, Apache, Mono (instead of .NET), mod_mono (which is the bridge between the Apache web server and the Mono runtime) and either MySQL with Connector/.NET or PostgreSQL with npgsql. If you use MySQL and don't want to buy a commercial license, you have to open source your application under the GPL. In my experience, the MySQL ADO.NET connector works better than npgsql for PostgreSQL, but the latter is licensed under the BSD license and thus also free for proprietary use. Of course, there's also an ADO.NET provider for SQLite.
Mono does a great job for ASP.NET applications; unlike the Winforms-GUI parts, it's very mature and battle-tested. In your case, I'd seriously think about using Mono instead of Microsoft's .NET stack. You can still develop under Windows: Download Mono for Windows and SharpDevelop and configure SharpDevelop to use Mono's compilers and runtime instead of .NET.
If I were you, I would just rent a web-server. It will save you a lot of headaches and overhead, especially if you want to release the game commercially.
Yes, all the data would be stored inside a database, and you would need to use SQL, and lots of it.
Thanks for the help everyone.
I do have a C# book, and know how to code C# to an extent.
And I also have Python as well.
I think I'll learn a little more C++ and then start on C# and Python.
Do I need to learn DirectX for C#?
My main interest is Game Development by the way, I am particularly
interested in online games so thats why I want to know Networking.
Thanks again everyone,
The Mighty WERDNA(Lord Of Darkness)