Get the latest Education e-news
 

Go Back   Game Career Guide Forums > Programming
Forum Home Register Members List Mark Forums Read

Closed Thread
 
Thread Tools Display Modes
Old 11-10-2008, 11:50 PM   #31
Protector one
Moderator

Activity Longevity
2/20 17/20
Today Posts
1/11 ssssss684
Location: Netherlands
Default

Quote:
Originally Posted by Claxon View Post
but then has anyone ever seen any non-hacky game code?
Surely it must exist. Somewhere. We can't all be hacks.
__________________
My name is Louis. Hi!
Uh oh! The princess is in another signature!
Protector one is offline  
Old 11-11-2008, 04:28 AM   #32
Duckman
Member

Activity Longevity
0/20 17/20
Today Posts
0/11 sssssss84
Location: Tuckahoe, NY
Default

Well I was finally able to get paddles and balls on the screen! I feel like I accomplished the simplest of things probably to you guys, but at least I am not a total failure. Although I feel that I probably will not finish this in time, I want to thank you guys ahead of time for your help and also kicking my butt into gear to start doing my own stuff. Thanks a bunch, your games look good so far, I just want to play! Can I be QA Lead on these?
__________________
Mike M
Facebook Profile LinkedIn Profile
Duckman is offline  
Old 11-11-2008, 04:50 AM   #33
Claxon
Senior Member

Activity Longevity
0/20 17/20
Today Posts
0/11 ssssss345
Location: London
Default

QA lead? You want to sit at your pc, browsing your e-mails all day and telling your minions to "test it again"?

If your balls and paddles are drawing the rest is quite simple, declare 2 float variables to store the balls speed (one is the X axis speed, the other is the Y axis speed), then every update add the speed values onto your balls position. Then if the ball hits the walls on the top or bottom reverse the Y speed ( ySpeed = -ySpeed; ) and the ball will bounce. Same for the X speed value if it hits a paddle. You really don't have far to go.

Ps. What I've said there is a very basic way to get the ball bouncing. You may want to improve on it later, by increasing the ball speed slightly each time it bounces, or making it change direction depending on where it hits the paddle.

Last edited by Claxon : 11-11-2008 at 04:52 AM.
Claxon is offline  
Old 11-11-2008, 04:59 AM   #34
Gshonk
Moderator

Activity Longevity
0/20 20/20
Today Posts
0/11 ssssss831
Location: Philadelphia, PA
Default

Quote:
Originally Posted by Protector one View Post
Surely it must exist. Somewhere. We can't all be hacks.
Yes it does, it is called architected code, if you plan out what you are going to code you should not need to have so many hacks. Really this just comes with time this is something they are still trying to teach me at work. Plan then code. I like to just jump in and code, but I am starting to realize if you plan it out it works so much better.

But if you are fixing bugs then no there is no non hack code
__________________
Grant Shonkwiler()
"I would love to fix the world if someone would just give me the source code"
Website Industry blog LinkedIn
Gshonk is offline  
Old 11-11-2008, 07:19 AM   #35
Duckman
Member

Activity Longevity
0/20 17/20
Today Posts
0/11 sssssss84
Location: Tuckahoe, NY
Default

Quote:
Originally Posted by Claxon View Post
If your balls and paddles are drawing the rest is quite simple, declare 2 float variables to store the balls speed (one is the X axis speed, the other is the Y axis speed), then every update add the speed values onto your balls position. Then if the ball hits the walls on the top or bottom reverse the Y speed ( ySpeed = -ySpeed; ) and the ball will bounce. Same for the X speed value if it hits a paddle. You really don't have far to go.
So I currently have a struct for the ball that has x position, y position, xspeed, yspeed, and image variables. I will be updating that and creating an update function that will feed the paint function the current parameters of that balls position. Do I have the general idea down? Sorry for the annoyances, this is my first game and I just want to make sure I am on the right path.
__________________
Mike M
Facebook Profile LinkedIn Profile
Duckman is offline  
Old 11-11-2008, 12:57 PM   #36
TG1
Super Moderator
 
TG1's Avatar

Activity Longevity
0/20 17/20
Today Posts
0/11 ssssss271
Location: New York
Default

Hmmmm, *cough*
I really have to ask, because I really have no idea how this compares to others:
I decided to look into Dark GDK today, as a possible framework to start writing games with (Just to clarify - I have been a programmer for 11 years, but never actually wrote a game). I started reading the tutorials at 21:00, and by around 23:40, using Dark GDK's 2D game template, I managed to have 2 puddles, a ball (both simple bitmaps), collision detection (with puddles and walls), player movement for the first puddle and a (very simple) AI movement for the second puddle. it's not perfect yet (The collision detection still doesn't work perfectly and there is no scoring system), and I'm not sure I'll manage to make something special out of it by the dead line, so I'm not sure I'll submit it.
My question is, if anyone here knows Dark GDK, is this considered good time for this framework? (Again, I really really really don't know ).

Another question - I'm having trouble with the 2nd puddle's AI, if I let it go towards the ball it always catches it, if I try to add some sort of penalty it never catches it, any advice?

Oh, and once I make it all pretty and nice (as nice as a programmer with no art capabilities can make it), will this be a good portfolio starter peice?
__________________
Tamar G
My web site
Linkedin profile
Facebook profile

Last edited by TG1 : 11-11-2008 at 01:16 PM.
TG1 is offline  
Old 11-11-2008, 02:14 PM   #37
Claxon
Senior Member

Activity Longevity
0/20 17/20
Today Posts
0/11 ssssss345
Location: London
Default

Quote:
Originally Posted by Duckman View Post
So I currently have a struct for the ball that has x position, y position, xspeed, yspeed, and image variables. I will be updating that and creating an update function that will feed the paint function the current parameters of that balls position. Do I have the general idea down? Sorry for the annoyances, this is my first game and I just want to make sure I am on the right path.
Yes that's right. I tend to keep my game loop fairly simple, it will call two functions, the first called Process() (or Update()) that handles the movement / AI / Game States etc, and another function called Paint() that deals exclusively with drawing the game (you don't want to do processing update within your draw loop). In this system the Draw function would simple get the position of the paddles and the ball, and draw them at that location. The process loop would update the position and speed values, and check for collision.


Quote:
Originally Posted by TG1 View Post
My question is, if anyone here knows Dark GDK, is this considered good time for this framework? (Again, I really really really don't know ).
Having never used Dark GDK I can't really say, but a pong clone shouldn't take you long at all (an experienced game programmer could make it in under an hour). If you're experimenting with things though and learning the system, then the time doesn't matter, providing you learn from it (in this case it would only improve your performance at future DarkGDK projects).

Quote:
Originally Posted by TG1 View Post
Another question - I'm having trouble with the 2nd puddle's AI, if I let it go towards the ball it always catches it, if I try to add some sort of penalty it never catches it, any advice?
Give the AI a maximum paddle speed. and only have it move when the ball has passed a certain point (eg. past the centre of the play area). You may also want to increase the ball speed each time the player or AI hit it. That way you can make the ai quite accurate at first, but as the ball speeds up and has more lateral velocity (forcing the AI move more), the AI will struggle to keep up. This gives the player a good challenge, and allows you to tweak the difficulty level easily too. Other behaviors for the AI could be to always follow the balls position, or to move back to the centre when the ball is traveling away from it.

Quote:
Originally Posted by TG1 View Post
Oh, and once I make it all pretty and nice (as nice as a programmer with no art capabilities can make it), will this be a good portfolio starter peice?
More than likely 'no'. If you make it into something like what my version is intended to be like (3d/cool graphics, particle systems, power-ups, perhaps multi-player, unique game mechanics) then yes it could go on your portfolio, but if it's a straight pong clone, it's not even worth mentioning (like I said above, anyone reading your portfolio could probably get the same result in an hours work).
Claxon is offline  
Old 11-12-2008, 10:02 PM   #38
Duckman
Member

Activity Longevity
0/20 17/20
Today Posts
0/11 sssssss84
Location: Tuckahoe, NY
Default

Quote:
Originally Posted by Claxon View Post
Yes that's right. I tend to keep my game loop fairly simple, it will call two functions, the first called Process() (or Update()) that handles the movement / AI / Game States etc, and another function called Paint() that deals exclusively with drawing the game (you don't want to do processing update within your draw loop). In this system the Draw function would simple get the position of the paddles and the ball, and draw them at that location. The process loop would update the position and speed values, and check for collision.
I am having difficulty drawing the paddles when the user moves them using the keyboard. I am updating the x or y coordinates for each move and passing it to the BitBlt() function for bitmaps, but it does not seem to draw anymore once I get my initial draw on there. I am not sure exactly what I am doing wrong but I've been trying all ways to get this done. I am just showing my n00bie colors lol.
__________________
Mike M
Facebook Profile LinkedIn Profile
Duckman is offline  
Old 11-13-2008, 12:18 AM   #39
Claxon
Senior Member

Activity Longevity
0/20 17/20
Today Posts
0/11 ssssss345
Location: London
Default

Is your draw() function being called repeatedly? It sound like either draw is only being called once or your x & y positions are not being updated. For the second problem, this could be a pass by reference / pass by value issue depending on how you've done your code. So your update function may be updating a copy of your paddle's position rather than the actual one your draw method is using. If this is the case you could make sure your x / y coordinates are in a global variable, and have your functions edit that, instead of passing the x & y coordinates into other functions as parameters. (I hope I've made that understandable.

If you like you can post the code for your paint & processing functions, so we can help locate the problem.
Claxon is offline  
Old 11-13-2008, 05:57 AM   #40
Protector one
Moderator

Activity Longevity
2/20 17/20
Today Posts
1/11 ssssss684
Location: Netherlands
Default

Man, I hope I'll finish my Pong in time and get some feedback... It's turning out pretty kooky and I'm digging it myself, although I can totally see how others might think it is a boring and buggy mess. :P
__________________
My name is Louis. Hi!
Uh oh! The princess is in another signature!
Protector one is offline  
Closed Thread


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
All times are GMT -8. The time now is 06:29 AM.






UBM Tech