FAQ Search
Memberlist Usergroups
Profile
  Forum Statistics Register
 Log in to check your private messages
Log in to check your private messages
Moonpod Homepage Starscape Information Mr. Robot Information Free Game Downloads Starscape Highscore Table
War Pong
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Post new topic   Reply to topic    Discussion Pod Forum Index -> Game Talk View previous topic :: View next topic  

Poll Result
  How good is War Pong?  
 
It's super!
9%
 9%  [ 1 ]
It's a good distraction.
27%
 27%  [ 3 ]
It's alright, but you know...
18%
 18%  [ 2 ]
Could be better.
9%
 9%  [ 1 ]
It's bad, but it could be worse.
9%
 9%  [ 1 ]
This sucks! Why did you make me waste my time on it?
27%
 27%  [ 3 ]
 
  Total Votes : 11  

 Author
Message
Konedima
Grammar Police
Grammar Police


Joined: 25 Oct 2003
Posts: 1068
Location: Sydney, Land of Censorship



PostPosted: Sat Dec 30, 2006 9:29 am    Post subject: Reply with quote

As a postscript to my last post, I'd just like to mention that I'm starting work on the C++ version of War Pong.

To be honest I'm not sure if I'm ready, but from reading online tutorials I've taken down plenty of my own notes that I can use. I do however feel that right now, the best way to learn is to do, and then see what problems come up and how to fix them.

What I'm trying to do different this time is that I will be documenting my code much more thoroughly, and maintaining a list of variables and functions. Because this code will (presumably) be much more read (because face it - C++ code is more interesting than a souped up BASIC) I'm trying to make it easier to understand than before. Also, all the extra features that were just added on top of BB versions I will try and integrate more.

I'm still looking for porting volunteers, particularly Mac, but if I need help I will post here (and expect a happy answer). I already have three questions:
1. How do you set the window title?
2. How do you get a string from the command line options? I'm planning to do skin launches like the (recent) BB version unless anyone has a better idea.
3. How do add a string to a filename to be processed?
Back to top
View user's profile Visit poster's website
James



Joined: 28 Nov 2002
Posts: 153
Location: Sheffield



PostPosted: Sat Dec 30, 2006 11:52 am    Post subject: Reply with quote

Are you using straight win32 or MFC or some other library?

If it's win32, then you set the window title in CreateWindow(), and can change it later with SetWindowText().

Assuming it's a windows app, the command line string is passed in to WinMain. Your WinMain will be something like:

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)

With lpCmdLine being the command line string.

Not sure what you mean with the third question.
Back to top
View user's profile
Konedima
Grammar Police
Grammar Police


Joined: 25 Oct 2003
Posts: 1068
Location: Sydney, Land of Censorship



PostPosted: Sat Dec 30, 2006 9:21 pm    Post subject: Reply with quote

Thanks for the help, but I'm not sure if it helps me (I'm using Allegro, not any Windows libraries). Even if it does, could you dumb down the second one a bit? Much as I hate to admit it, I'm not that good yet. And by the third one, I mean I'm looking for the equivalent to this snippet from the BB version:
Code:
skindir$+"\ball.bmp"
skindir$ in that is a string containing a folder name, which is set earlier.

While I'm at it, I'm noticing that many of my (16-bit) bitmaps are just showing up as black boxes when using 16 bit colour (which is what War Pong uses). If I change the colour depth, some still show as black boxes, but some show properly (it's pretty much random which ones, but their behaviour is persistant). 8 bit versions usually work though. Ideas, anyone? Am I missing something?
Back to top
View user's profile Visit poster's website
Weeble
Starscape Jedi
Starscape Jedi


Joined: 25 Apr 2003
Posts: 1143
Location: Glasgow, Scotland



PostPosted: Sat Dec 30, 2006 9:55 pm    Post subject: Reply with quote

Strings are pretty complicated in C and C++. I'd suggest using C++ strings when you can, rather than C char*s. (In C, there's no "string type". A char* is a pointer to a character, or in most cases, an array of characters. I'm not going to go into all the details right now.) C++ strings are a little more verbose, but quite a bit simpler to understand. They save you from worrying about memory allocation and buffer overruns.

I don't have a compiler to hand, so I'm not 100% sure about this, but it's something like what you want:
Code:
#include <string>
using std::string;

//...

{
     // This creates a new, empty, C++ string.
    string strSkinPath();

    // This appends strSkinDir onto it. strSkinDir can
    // be a C++ string or a C char*.
    strSkinPath.append(strSkinDir);

    // This appends "\ball.bmp". The backslash must
    // be doubled because it's an escape character.
    strSkinPath.append("\\ball.bmp");

     // someFunction needs a C char*. c_str()
     // converts from C++ string to C char*.
    someFunction(strSkinPath.c_str());
}

I'm assuming that strSkinDir is declared and initialised somewhere in the same way skindir$ is already declared before your example.
Back to top
View user's profile Visit poster's website MSN Messenger
Weeble
Starscape Jedi
Starscape Jedi


Joined: 25 Apr 2003
Posts: 1143
Location: Glasgow, Scotland



PostPosted: Sat Dec 30, 2006 10:02 pm    Post subject: Reply with quote

Also:
http://www.allegro.cc/manual/api/using-allegro/set_window_title

EDIT:
The command-line arguments come into your main method like this:

Code:

#include <iostream>
using std::cout; // cout is standard text console output.
using std::endl; // endl is a special code for a new-line and buffer flush.

int main(int argc, char* argv[])
{
    // argc is the number of tokens on the command line.
    // argv is an array of char*s, one for each argument.
    // (The first token, at index 0, will normally be the name of your exe.)
    // This just loops through all the arguments and prints them out:
    for (int i=0; i!=argc; ++i)
    {
        // This means "write argv[i] to the stream called
        // cout, followed by a new line."
        cout << argv[i] << endl;
    }
}


That can be a pain if you're trying to read numbers, but it should do okay for strings. An alternative might be to read settings through Allegro's configuration file. http://www.allegro.cc/manual/api/configuration-routines/
Back to top
View user's profile Visit poster's website MSN Messenger
Konedima
Grammar Police
Grammar Police


Joined: 25 Oct 2003
Posts: 1068
Location: Sydney, Land of Censorship



PostPosted: Sun Dec 31, 2006 3:36 am    Post subject: Reply with quote

Thanks for all that Weeble, I'll put it in (or work off it) when I have a chance. Still, does anyone have any idea what my graphics problem is? It seems to be the most pressing issue. By the way, why are you talking about C++ strings being better? I'm using C++.
Back to top
View user's profile Visit poster's website
Konedima
Grammar Police
Grammar Police


Joined: 25 Oct 2003
Posts: 1068
Location: Sydney, Land of Censorship



PostPosted: Sun Dec 31, 2006 10:40 am    Post subject: Reply with quote

Since I like posting in my own thread, I'll update you with the news that I've found a workaround for my image problem. If I set all the graphics as indexed colour, they seem to work fine (the ones I've tested so far). I've been testing using the Retro War (first skin) graphics, and not only do they work, but they are much smaller (I'm not sure how well that would work for other skins, because the Retro War images at most have 25 colours, and most have 2 colours). To be exact, the Retro War skin compressed is a bit over a third as large now, and uncompressed is a bit over a third as compressed, so this should cut down on download sizes. It is a problem though because it makes editing hard(er) and skins have to be specifically updated for it (although it would probably not be hard to make a Photoshop macro to do it). There is probably a way to make skins work without editing them (there's heaps of stuff in Allegro about colour conversion and palettes that I've tried to use but without luck).
Back to top
View user's profile Visit poster's website
Weeble
Starscape Jedi
Starscape Jedi


Joined: 25 Apr 2003
Posts: 1143
Location: Glasgow, Scotland



PostPosted: Sun Dec 31, 2006 1:18 pm    Post subject: Reply with quote

C++ was created as an improved C. Most C programs will compile in a C++ compiler. So you have a choice of using C style strings or C++ style strings in your programs. Indeed, you can't entirely avoid using C style strings - string literals (when you enter an actual string in quotes in your code) are C style strings. Furthermore, Allegro is a C library, so you need to give it C style strings - it doesn't know about C++ style strings.

So, you might ask, why bother with C++ style strings at all? Largely because it saves you from worrying about whether your C style strings are long enough. C style strings are simply fixed-length arrays, with a special marker character (NUL) stored in them somewhere to indicate the end of the string. If you try to put more characters than will fit in your C style string, memory can get corrupted, resulting in hard to pin down bugs. If you "over-fill" a C++ string then it will just allocate some more memory for itself and you don't need to worry about it.

I'd recommend getting yourself a good book on C++. I have The C++ Programming Language (Third Edition), and it's pretty much the most popular. There's a real danger in learning C++ by stumbling around in the dark and reading other people's C and C++ code you find on the 'Net. C++ is an amazingly powerful language, and it's easy to shoot yourself in the foot.

As for your graphic problems, I'm sorry, but I've never used Allegro, so I have no idea.

EDIT - As pointed out by SethP, I've vastly oversimplified my discussion of C style strings. The array terminated by a NUL character is just one common way of doing it, but by no means the only one. I don't think you're likely to need to know about any others, though.


Last edited by Weeble on Sun Dec 31, 2006 1:25 pm; edited 1 time in total
Back to top
View user's profile Visit poster's website MSN Messenger
SethP



Joined: 24 Apr 2006
Posts: 302
Location: Connecticut, USA



PostPosted: Sun Dec 31, 2006 1:21 pm    Post subject: Reply with quote

konedima wrote:
SethP wrote:
I've updated my profile to show my email, so feel free to drop me a line.
Your profile page isn't showing your address. Is "Always show my e-mail address" set to yes in the preferences section? I probably shouldn't have posted my address for the spambots to get but people can always contact me via the contact page on my Sourceforge user profile (http://sourceforge.net/users/konedima).


Well, I'm not sure why the board doesn't want to show my email address. Oddly enough, it displays all the other contact information if I stick something in it. So, taking advantage of that, my MSN messenger info is actually my email. I don't actually have an MSN messenger account, but it still works well enough.

konedima wrote:

By the way, why are you talking about C++ strings being better? I'm using C++.


In C++ (and C), there's about a million different ways to do strings. The basic version, which is just a long array of characters, isn't very graceful. It stores the string well enough, but it takes a lot of programmer effort to do anything else with it. That's why, in C++, programmers have created a string class to allow easier manipulation of strings. Good ol' C doesn't support object oriented programming (you can't write classes), so that's why the array of character type strings are referred to as C strings, and the class based are referred to as C++ (although technically the default in C++ is still to use the C string). Hopefully I cleared that up a bit and didn't just confuse you.

For the graphics issue, would it be possible to take a look at your code where you load the bitmaps and then where you display them?
Back to top
View user's profile MSN Messenger
Konedima
Grammar Police
Grammar Police


Joined: 25 Oct 2003
Posts: 1068
Location: Sydney, Land of Censorship



PostPosted: Mon Jan 01, 2007 9:39 am    Post subject: Reply with quote

I thought another of my frequent progess updates was in order. The good news is that I have a fully functioning pong game, but I still need to include the menus and the battle system. I would say think War Pong 0.01 level of completion, but I just remembered the first release was version 0.03 (also, before that, it was called "Battle Pong" - I changed it because that name was taken on Sourceforge - that project has only had two released versions and the last one was released in November 2003).

I still have no idea what's causing the graphics issue I've described (and complained about) earlier, but it's not on the urgent list of problems to fix (because I've found a workaround that works, it's just annoying).
Back to top
View user's profile Visit poster's website
Konedima
Grammar Police
Grammar Police


Joined: 25 Oct 2003
Posts: 1068
Location: Sydney, Land of Censorship



PostPosted: Thu Jan 18, 2007 9:24 pm    Post subject: Reply with quote

The C++ version of War Pong is still coming along... slowly. Since I'm still at the stage where I can make design changes if I want, I'd like some feedback on an idea I'm thinking of toying with. Basically, this is how it is now:

I'm thinking of moving the War Pong logo and the scores to a header bar without reducing the size of the playfield (because it only runs in windowed mode, I don't have to worry about supported monitor resolutions and such) which would look something like this (as a 5-minute photoshhop mockup, anyway):

So please, tell me what you think of that idea.
Also something I've decided on is that since most sections of the code run in their own functions I can therefore create a somewhat different mode of gameplay while using a lot of the same code, I will, so there will be mods (not sure what to call them) for game modes (I have a couple of ideas already).

And while I'm posting I'll just point out that I still have no idea about the bitmap problem that I mentioned earlier, so if anyone has any ideas about that, crazy as they may be, I'm happy to hear them.

Also since I'm here, does C++ have an equivalent to BB's for...each system that I use for the bullets (if you're not sure what I mean just look at the source code for the latest (or any) BB version), and if it doesn't, what's the best system to use in the situation?
Back to top
View user's profile Visit poster's website
Rup



Joined: 19 May 2003
Posts: 363
Location: London, UK



PostPosted: Thu Jan 18, 2007 11:00 pm    Post subject: Reply with quote

Konedima wrote:
Also since I'm here, does C++ have an equivalent to BB's for...each system that I use for the bullets (if you're not sure what I mean just look at the source code for the latest (or any) BB version), and if it doesn't, what's the best system to use in the situation?

How are you storing the bullet data? Once you've got that it should be obvious. If you're using an STL container, e.g. a list<Bullet>, then you'll have something like:
Code:
#include <list>

class Bullet
{
    // Data about a bullet
};
typedef std::list<Bullet> tBulletList;

void updateBullets()
{
    tBulletList listBullets;

    tBulletList::iterator itBullet = listBullets.begin();
    for(; itBullet != listBullets.end(); ++itBullet)
    {
        Bullet& b = *itBullet;
        // do stuff
    }
}
or if you're using a plain array then you might have something like:
Code:
class Bullet
{
    // Data about a bullet
};

void updateBullets()
{
    Bullet* arrayBullets = new Bullet[32]; // for example
    int nCountBullets = 10; // for example

    int i=0;
    for(; i < nCountBullets; ++i)
    {
        Bullet& b = arrayBullets[i];
        // do stuff with b
    }
}
In this case you're limited to the number of bullets you can store (32 here) unless you have code to reallocate the array to manage that, etc.

These code fragments are just for illustration, you'd need to have the bullet list<> or the array/count as globals or member variables of your game or playfield class or something, and there's plenty more ways to do it e.g. by using your own home-made linked list. And even if you are using STL containers then maybe list isn't the one for you, maybe another one is more appropriate, and it you read the docs for <algorithm> there's probably an iterate-through method in there you could use instead if you really wanted to (but I doubt it'd simplify things).

So, in summary: what you should use for for...each depends on other design decisions you've made.

As a quick post-script, if you're using C++ you should try and get into the 'const' habit early: tell the compiler when you're not expecting to change something so it can warn you if you do accidentally. Then the STL loop above becomes something like:
Code:
    tBulletList::const_iterator itBullet = listBullets.begin();
    for(; itBullet != listBullets.end(); ++itBullet)
    {
        Bullet const& b = *itBullet;
        // do read-only stuff, e.g. read co-ordinates from b
        // and draw the bullets on screen without updating data
        // in b
    }
And finally sorry if I've gone off on one about stuff you don't know about yet. Stick with C++ and you will soon enough Smile

[edit] One more thing: this is my C++ coding style. Don't worry if your code doesn't look anything like it as long as it's neat and tidy. Everyone lays out their code differently, everyone names variables differently, everyone's got their own quirks (e.g. I rarely ever use the init bit of a for, I've used old MSVCs long enough Smile), everyone uses different indent sizes (but if it's not 4 you're wrong Very Happy). If there's more than one person working on a project you should keep it consistent between you all though.
Back to top
View user's profile
Konedima
Grammar Police
Grammar Police


Joined: 25 Oct 2003
Posts: 1068
Location: Sydney, Land of Censorship



PostPosted: Sun Jan 21, 2007 3:17 am    Post subject: Reply with quote

I'd still like an answer to my above design question (thanks Rup for all of that, I'm still going through it), I'm wondering if anyone would be interested in a little competition while I'm working on it.

The prize would be you get your own easter egg in the next version of War Pong somewhere (it can be whatever, within reason of course, and put anywhere in the game, again within reason) unless someone could think of a better one. The competition would be: I can create an almost unbeatable AI routine for War Pong (it still plays within the rules) so anyone who could beat the AI in the competition version (just the incredibly hard single player mode with one skin) will get a code, and the first one to post that code here wins.

It's just a bit of quick fun, but I consider the community aspect of War Pong important, since all of you help me so much with this. As I said earlier I'm looking to see if anyone's interested in this before I get to work, but if I get just one yes, I'll do it.

Edit: Also included in the fabulous prize pack will be the latest build of War Pong C++. I'll also include the graphics needed, but to be honest I don't know what Allegro files I'll have to bundle in (perhaps someone could enlighten me on that) so it may or may not come with them.
Back to top
View user's profile Visit poster's website
Konedima
Grammar Police
Grammar Police


Joined: 25 Oct 2003
Posts: 1068
Location: Sydney, Land of Censorship



PostPosted: Mon Jan 22, 2007 10:33 am    Post subject: Reply with quote

I have to wonder: why is it people pay big bucks to get one line in Halo 3 but they won't prove their skill to get in my little game? Oh well...

By the way, has anyone made a skin for War Pong other than me? If you have, I'll be happy to include them when I finally release the next version.

Since I think a complete rewrite is a significant occasion, I'll want to include many new skins (maybe I'll have to add a heavy download the the light and regular versions).
I already have one skin ready (by a guest skinner, one of my brothers) and I've been toying around with a couple of ideas myself (meaning I have a couple of semi-complete skins).
Back to top
View user's profile Visit poster's website
Konedima
Grammar Police
Grammar Police


Joined: 25 Oct 2003
Posts: 1068
Location: Sydney, Land of Censorship



PostPosted: Fri Jan 26, 2007 7:04 am    Post subject: Reply with quote

Just a quick note: I've opened a War Pong development blog at http://warpong.sourceforge.net/blog/.
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Discussion Pod Forum Index -> Game Talk All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Page 6 of 9

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group