Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / My first ever program, tips and constructive critisms welcome.

Author
Message
Scarface
17
Years of Service
User Offline
Joined: 21st Oct 2006
Location:
Posted: 2nd Aug 2008 00:23
Well here it is.



It's 2 player pong, player 1 uses the left and right arrows, player 2 uses Z and X, space starts the ball rolling.

There is no end, the points just keep clocking up, it does the job, and I'm pleased with the outcome, it's the first program I've ever written. I have no real programming experience apart from NWScript, I hope it's at least ok for a firsty.

- Scarface
Scarface
17
Years of Service
User Offline
Joined: 21st Oct 2006
Location:
Posted: 2nd Aug 2008 14:27
No advice or critique?

I have modified the game a bit more, to allow inputing player names, and a couple of other small tweaks.



What do you think?

Also I was wondering about how to change variables globally. I have been using a struct for this purpose which to me seems like a pain in the backside, is there an easier way?

Cheers

- Scarface
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 2nd Aug 2008 16:10
It gives me this error as soon as the lower bat touches the ball
Unhandled exception at 0x004cffd6 in Dark GDK - 3D Game4.exe: 0xC0000005: Access violation reading location 0x00000bbc.
And instead of z and x i would make the controls a and d
Scarface
17
Years of Service
User Offline
Joined: 21st Oct 2006
Location:
Posted: 2nd Aug 2008 16:35
I am playing it now, it works perfectly ( or at least as intended )without any errors, the error must your end

I will make the controls for player 2 'a' and 'd', any other advice on the actual coding?

- Scarface
Scarface
17
Years of Service
User Offline
Joined: 21st Oct 2006
Location:
Posted: 2nd Aug 2008 16:40
Hmmm actually now for some reason it is giving me that error, I will see what I did to cause it and then post the fixed version, I'm very confused now it was working fine 5 mins ago...

- Scarface
Scarface
17
Years of Service
User Offline
Joined: 21st Oct 2006
Location:
Posted: 2nd Aug 2008 16:55
Ok I don't get it, the error is from these two lines:



Which are located in the DisplayScores( ) function, when I comment these out, the game works as intended, but without the player names on display.

Any idea why this would cause a crash when the ball hits either bat?

- Scarface
Scarface
17
Years of Service
User Offline
Joined: 21st Oct 2006
Location:
Posted: 2nd Aug 2008 17:08 Edited at: 16th Feb 2013 01:35
Ok fixed it ( kind of! ), only problem now is when you exit the game, it displays an error message telling me that the buffer is overloaded, but it works


I modified it a bit more, now the first player to 10 wins, I changed the player 2 controls to 'a' and 'd'.



So any advice on the coding please?

- Scarface
Scarface
17
Years of Service
User Offline
Joined: 21st Oct 2006
Location:
Posted: 3rd Aug 2008 13:31
Now I remember why I gave up on this before, the lack of help and support makes it impossible to advance on /sigh.

- Scarface
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 3rd Aug 2008 13:44
Do not forget this is the middle of the summer holidays - i would imagine a large percentage of our forum users are getting a tan somewhere atm and are not around to view and reply to the forums.

You're doing well! A good thing to do is to give yourself little exercises to complete. You can add modifications to this program to teach yourself stuff before moving on to a more complicated program from scratch. For example maybe you could make certain things happen when the player reaches certain scores? 20 points makes the game play a sound saying "great" or something?

You could try more complicated things like getting 50 points makes the game spawn a second ball so you have to start playing with two at once!

or perhaps randomly the game could spawn a power up (which for the sake of keeping it simple could just be a different coloured ball) which if the player touches it with their bat then it gives them a power up. Anything from bonus points to making their bat bigger or smaller.

Why not try some stuff like that?

As for actual coding advice, the only real problem I see in your code (at a very quick glance) is you've used a full (or literal) path to a file, your pong_bounce.wav. You shouldnt do this as on another persons pc they probably wont have even a D drive let alone the same folders as your pc! You should change the path so it just has the file name in it. Then the program will try and load the file from where your exe is located.

If you are debugging the program from visual studio then the exe would be in <project folder>/Debug/. Its best if you keep your wav and other data files in your project folder (ie, same folder as source code) so if you want to do that and you want to load the file from within debug mode you could write the path "../pong_bounce.wav". the ".." just makes it look in the folder above the one its already in

Hope some of that helps you in some way.

Scarface
17
Years of Service
User Offline
Joined: 21st Oct 2006
Location:
Posted: 3rd Aug 2008 14:08
Thanks for the advice, I appreciate it.

And about my frustration with support, I understand it's holiday season, but I have tried this a couple of times before over the last 1 and ½ years or so, when it hasn't been holiday season, and I felt a real lack of support which ended up me giving up completely.

I have always been interested in programming, since I was 10 years old trying to learn Amsoft Basic ( Amstrad Basic if you remember it ), so this has always been a passion for me, but at that age I was unable to grasp the complicated manual so it didn't go far, I then just played with some languages over the years without any real advancement, until I found a game called 'Neverwinter Nights' which had it's own toolset for building modules and a language called 'NWScript' which is C based, with which I taught myself to be an pro scripter over the course of 5 years, so naturally I wanted to learn a familiar language and didn't opt for DB or DBPro, I went straight to this one, but I feel the tutorials are almost non-existant for GDK, and while I understand DB and DBPro are just more simplified versions, using a large DBPro tutorial for GDK is frustrating as you need to convert them to GDK functions, and often check up on other things as the structure can be a little different, so it makes it even more stressfull to learn, and I can't imagine how hard that would be for a complete noob to any language lol.

I will take on board what you said and develope my abilities in this pong game until I have exhausted everything possible in this project, cheers.

- Scarface
Orient
16
Years of Service
User Offline
Joined: 2nd Aug 2008
Location:
Posted: 4th Aug 2008 04:56
Scarface, I'm running into the same problem as you.. there are NO tutorials, and no support really. I've searched Amazon, and no books have been written on DarkGDK (a few on DarkBASIC, bus as you said.. too much of a pain). Unfortunately, I'm not quite as advanced as you at this point, but I encourage you to keep it up if this is something you're passionate about.

One thing you may want to try is getting another game created using DarkGDK and just look through the source code. See if that gets you anywhere. Good luck, and nice first game =).
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 4th Aug 2008 20:57
yeah guys. we all had this problem when we started with GDK. we are trying to create a wiki to help newcomers and as a reference, but it is a slow process. If you want to help, or use it (there is one tutorial) then go to DarkGDK.wikia.com
Scarface
17
Years of Service
User Offline
Joined: 21st Oct 2006
Location:
Posted: 4th Aug 2008 22:10
Hi Orient, I will try to keep at it, but I can only have so much patience lol, lucky for me I was able to learn alot about C because I taught myself a C based scripting language developed by 'Bioware' the big game developers, so they had ( and still do ) a very active website and forums, where I could post and have a question answered in minutes by many posters, so I got a bit of a head start, I can only imagine your frustration as mine is pretty high

I'm thankful to jezza and Sephnroth for helping me out, I just hope I can get to a more advanced level as soon as possible so that I don't have the need for so much help.

Thanks for the link btw, I hope this wiki will expand well in the near future.

And Orient, I'm not advanced at all, far from it, in fact I'm a mere window cleaner who sucks at math I just have a drive for programming, but if I can help you out in any way, just give me a shout.

Cheers guys.

- Scarface
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 5th Aug 2008 01:25
Its becomming increasingly clear that the beginners tutorial situation is not only lacking, but desperate. I've got a half finished 2D programming tutorial for absolute beginners that i'll have to press hard to finish - its just so hard to find time!

But i'll give it a good go

Scope 51791
16
Years of Service
User Offline
Joined: 25th Jul 2008
Location:
Posted: 5th Aug 2008 05:25
Hey, after seeing this, I felt like making my own pong game. I did some images and sprites for the game. Then I started coding the game. I make both of the move on user input. I got the ball to start moving only on the x axis so basically it goes back and forth. Then I tried playing around with it but I can't seem to make the ball bounce in the right direction. Say the player was on the left, the ball was coming to him at an angle going up. So therefore when it bounce off of the player, it should bounce going up until it hits the wall. How could you write it out so it does that. Here is my code.



This part of the code:



Means that based off of pYchange it determines the ballAngle, if the ball is coming up or down. Anyone can help me out in making it more like a pong game. THANKS.
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 5th Aug 2008 09:16 Edited at: 5th Aug 2008 09:17
Quote: "but I feel the tutorials are almost non-existant for GDK"


Quote: "there are NO tutorials, and no support really. I've searched Amazon, and no books have been written on DarkGDK (a few on DarkBASIC, bus as you said.. too much of a pain)"


Keep in mind that we are talking about a rather small section of TGC. Of course there aren't books. It's only just been made free. Besides, we're talking about C++. It's the most widely used language today. There is so much about C++ on the internet, that you should do fine without any GDK-specific tutorials. If this is not the case, then you need to either spend time better learning C++, or move to a simpler language for awhile.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 5th Aug 2008 13:05
If there are not books written about GDK then why not write one

Niels Henriksen
www.tales-of-the-realms.com
if Microsoft can sell software with bugs, so can I.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 5th Aug 2008 16:55
Quote: "If there are not books written about GDK then why not write one"


Someone at the Pop Cap Developers' site had inquired as to writing a book around their API. He had seriously gotten into writing it but probably had a look at the financial aspect of it and instead posted it as a series of articles in the forum. He's now found a site that's better suited for the purpose and is slowly putting his tutorials there.

Essentially, unless the subject is broadly popular, it's not going to be feasible to publish it. Heck, I had to dig to find a book on SDL and it's largely written around Linux, though it is multi-platform.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Login to post a reply

Server time is: 2024-09-30 03:16:21
Your offset time is: 2024-09-30 03:16:21