Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Online torpedo game

  1. #1

    Online torpedo game

    Hi. Me and my friend are just about to start a Torpedo game. And we have some ideas like the field will be handled as a 10x10 matrix and we can do most of the coding it's not too tough. What we don't know however is how will we be able to make this work online. How should we make the packages work but not too slow. And first of all how do we make the program send the packages. I don't know if there exists a topic about something similar like this if there is I am absolutely okay with just a link to that topic altough I haven't found anything like that. Thanks in forward.

  2. #2
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2
    I would suggest you have a read through some of the threads here.

    They should help you get an idea of what's involved. After that, you'll need to get a handle on what information you need to exchange between clients and then come up with some suitable structures/communications protocol.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  3. #3
    oh then it won't be as easy as we thought well anyways thanks. If I can get SDL work in this life maybe the game will be fine

  4. #4
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2
    Depending on how much data you need to transfer (and importantly, what data - synchronisation etc.), it can be quite easy.

    I don't know what compiler you're using, but lets say you're using Delphi, you can create a class descended from TPersistent. The data you want to transfer can be stored in that class as published properties... then you can make use of the streaming mechanisms in Delphi and say the Indy components and simply stream the class over the socket connection.

    I've never written a game that uses this kind of socket connection so I can't comment further, but I have used this technique to squirt 12MB objects over a TCP/IP connection without too many hitches. But, it doesn't have any real error detection etc. So you may be better off defining a communications protocol (I've always used HDLC as a base for such protocols) which can handle failed transmissions and other errors such as corruption etc.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  5. #5
    I didn't get most of this since my skills in network programming... well let's just say you can't divide with it. Anyways this will be useful when I finally understand it so thanks. It's not your fault I assure you I'm just way too noob in this. I'm using free pascal. And I have never used ANY other includes and barely even use units except for crt. Altough I'm trying to get JEDI-SDL work I'm too noob to even do that. There's another topic of mine about that... So all this, a program with multiple components like not just a simple executable and maybe 1 or 2 binary and text files is totally new to me. I thought it would be so much more simple. They said Game Maker is good for start well game maker is nothing compared to this. It's like telling a 5 year-old to make the plans of a whole house after he've been playing with wood-cubes for a couple of hours. There I just pushed a button and there was my object I didn't need any constructor thing I don't even know what the hell is that but I see it everywhere in the examples. It's hard to learn from the examples when the theory of the coding is explained but I barely know the functions and procedures used because they're either Object Pascal or in units I've never used before. Altough if I could finally create an object and make it "work" somehow I would see, yes it is kind of similar to game maker but other than that, not at all. I don't even know how these work in pascal. I mean objects. Are their procedures executed as they exist? Or should I call them? Oh don't worry you don't have to answer these stupid questions I'll search for them but I'm just scared When I finally think I know a little about this langauge I find out how little exactly that is.

  6. #6
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    If you want to program in Object Pascal, just program in Object Pascal, it's not so scarry once you get into it more. As neat as Game Maker is, it won't really teach you how to use the tools or learn the language. Game 'design' concepts sure, but you need programming experience to really break ground in learning it. It'll come, just don't get too discouraged if it's not coming right away. We all went through this and we want to help so you are good to go as long as you keep trying and make the effort. Trust me, it's worth it.

    Along with this fine pep talk, I'm going to give a caution. I'd stay away from networking or online anything for now. Keep your game local. Networking is an aspect of game programming that can even make commercial game developers for EA Game cry. Save this for something that you will learn a bit later. Instead try your hand at simple rule-based AI for computer players or adding joystick/gamepad support so that you and a buddy can play and test it on one machine. You can do some cool stuff with both those areas without splitting your head open on networking so early.

    Games with simple yet an addictive quality will do you the most good. Your torpedo game seems like such a game. Keep the things you have to program to a minimum so as not to overload your project or you'll lose interests fast.

    Also check out my tutoruials on making an Artillery game I use Lazarus and JEDI-SDL and I provide the source code you can download and compile yourself. It might help you figure out your setup for making games too.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  7. #7
    Thanks I've already looked at your artillery tutorial but since that was over my level too I didn't get it too much but I found the landsmoothing procedure very interesting and other theories whiches understanding didn't do much with a (for me) complicated code. Yes I was thinking about that staying with offline games would be a right choice. First we will design this game for a simple PC if that is done maybe we will try to make it work online. As for the simple AI I already have a little experience in that. It would be a very interesting project writing an AI for a Torpedo game. I will think about that I would need some kind of method not just random shots. Maybe we will even add difficulty settings to make the game less boring. Now I have to go to class. The Biophisics test awaits me.

  8. #8
    Thanks I've already looked at your artillery tutorial but since that was over my level too I didn't get it too much
    The artillery tutorial is not really complicated IMHO. What is your programming experience so far?

    As you said, it is best to start things as simple as possible. Even after a lot of years of programming, I still underestimate many projects. Just take your time to learn SDL. Have a look at some examples/open-source-games and you'll learn alot.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  9. #9
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Would you say that you understand Object Oriented Programming and the Object Pascal language as well as just Pascal? If you have a hard time with OOP then I can see how you might have a difficult time with my tutorial. It is written with the assumption that you understand basic object class structures. I don't go much further into it than that, but if you are having trouble with the OOP portion of the code, I can understand where I lost you in it.

    I suppose I could start writing a couple of smaller beginner tutorials about the basics of objects and classes and their usage in a simple to learn way. At least that's how I learned it so at least from me I'd be able to explain it to you and others in a "plain" form of language. I'd offer the basics of SDL, but to be honest I think that our friends at 'Freepascal meets SDL' have that covered.

    Your torpedo game sounds like a good game to start with. I assume that the game mechanics will be much like Battleship, am I right? If so, this is good! Start with something like that. My first games where Pong, Arkanoid and Tron.(or Snakes or whatever other names it's given)
    Jason McMillen
    Pascal Game Development
    Co-Founder





  10. #10
    Yes I have serious troubles with OOP both with syntaxes and methods. My torpedo game would be like this:
    Each player has a 10x10 board (A..J and 1..10). On that you set up your ships by giving the coordinates. Then the players take turns and shoots at coordinates like A9. If there is a ship of the opponent player they can shoot again. If there isn't then it's the opponent's turn. When all parts of a ship has been hit it sinks. The player who first sinks all of the other player's ships wins the game. It is really not that hard. I'm working on that I finally got SDL working now. It would be possible to leave OOP out of this but I need to practise so I made an object for the AI. And anyways I think it's more practical to handle the AI variables and procedures as part of an AI object than totally global. However I get some stupid error I don't get... The parts of the code which could be related to the error look like these:

    Code:
    type
    sq=record
    x:integer;
    y:integer;
    end;
    PAI=^TAI;
    TAI=object
    currenttarget,nexttarget:sq;
    procedure ClearRegion(r:integer); {this is a basic AI procedure I'm not finished with it yet it is for making it not totally random}
    procedure Shoot(c1,c2:integer);
    end;
    
    var
    AI: PAI;
    Procedure AI.ClearRegion(r:integer);
    begin
    {This is not finished yet}
    end;
    Procedure AI.Shoot(c1,c2:integer);
    begin
    {This is pretty long and yet not complete}
    end;
    begin
    New(AI);
    {program parts which are not too important}
    Repeat
    AI.Shoot(AI.currenttarget.x,AI.currenttarget.y);
    Until RegionCleared(Region(AI.currenttarget.x,AI.currenttarget.y));
    {RegionCleared(r:integer):boolean and Region(c1,c2:integer):integer are functions defined correctly they work well I've made test programs for those.
    (the AI.ClearRegion procedure is called inside the AI.Shoot procedure it's not yet working correctly I know that but the errors I get seem to have nothing to do with that...)
    
    Now I've got two errors. First is like "Until expected AI.Shoot found". wtf??
    Second is at the definition of procedure AI.Shoot(c1,c2) it says "class" type expected. I've tried setting up PAI as class type and AI as PAI type but then it said: unkown identifier: class. how could class be an unkown identifier for God's sake????:D}
    
    end.
    Any ideas? I remember the times when I had errors like runtime error 103 or 201 with simple pascal and I didn't know what to do with them. Now they are like routines: "Oh error 103 must have called close(f); in a loop somewhere and forgot to Reset(f);". I know times will come when this will be the same with OOP but I'm not there yet.. And sorry for this superlong post if you didn't have the patience reading this through I understand if you did well thanks
    Last edited by WILL; 26-10-2010 at 04:57 PM. Reason: Added code blocks

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •