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.

Newcomers DBPro Corner / My First Try - Pong Game 2D - DBP

Author
Message
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 1st Jan 2005 02:07
Hello reader! Thanks for stopping by!

I have setted up my stage. I have created a background, the player #1 and the player #2. The disk (ball). I have placed them in the begining position.

My first question is regarding sprites. I cannot make my mind in how to make the sprite move. I use the MOVE SPRITE,1,5 command to move up and MOVE SPRITE 1,-5 to move down. But thats about it I cannot find how to make it move left and right. Can I do this with sprites? I'm using the right method or not?

My second question is regarding Sub rutines and functions. How do I know when to use what?

Thank you! I added my code.

- Just Me!

Attachments

Login to view attachments
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 1st Jan 2005 02:10
Sorry I also forgot to mention, that I'm having problems with the transparency of my .png is using the color black as the transparent color. is there any way to stop this and make it use the information from the .png file?

- Just Me!
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 1st Jan 2005 02:28
Well I desided that the borders should be sprites as well, that way is easier to determine where is the actual border. So the top and the bottom borders are sprites now.

- Just Me!
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 1st Jan 2005 02:33
This is just an update to the code, cleaning up a little bit. So if anybody is interested in helping me developing this phong game, please use this code thanks



- Just Me!
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 1st Jan 2005 02:37
Ooops! The code above had an error, here is the updated version. The code had the sprite numbers wrong placed.


- Just Me!
Dot Merix
20
Years of Service
User Offline
Joined: 15th Oct 2003
Location: Canada
Posted: 1st Jan 2005 03:12
There is an EDIT Button.



WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 1st Jan 2005 03:13 Edited at: 1st Jan 2005 03:14
Where? It doesnt show to me...

EDIT:

I found it... Duh! is not a button... Is text thats why I couldnt find it... Thanks for telling me...

- Just Me!
FoxBlitzz
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location: United States
Posted: 1st Jan 2005 03:45
Well, it looks a lot better than I thought it would be. I thought the graphics would be crap but they actually look pretty nice.

UNVIDIA GeFartFX 5600 Crud Edition
Featuring an unbeatable 0-1 FPS in 3DMark05!
If Return to Proxycon were a game, I would die before I saw the door open!
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 1st Jan 2005 03:57 Edited at: 1st Jan 2005 04:09
sub routines are used when you want to use variables that you have already specified earlier in your program in the sub routine, a function would be used if you wanted to use variables specific to that function, heres and example of each:

sub routine:


see, that uses the object that you specified earlier in the program, but only that one object, whereas a function is like this:



see, with the function to move the object up, you could use any object that you want with it, instead of just certain objects



this wasn't probably the best of help, but i tried

i have never used sprites before, so i dont know how you would move it right and left, maybe if u paste the sprite with different x positions/ like:

paste sprite 1,spritex#,sprite y 1
if leftkey() = 1 then spritex# = spritex# - .2

maybe that works, maybe not, u probably need help from someone whos actually used sprites, but you can try that if you want...

The Uknown Element Gaming Group
http://www.freewebs.com/tuegames/home.htm
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 1st Jan 2005 03:58 Edited at: 1st Jan 2005 04:01
Thanks mate Evil Monkey!

Thanks Shadowed Lightning that actually helped me understand more about sub rutines and functions.

Well here I added some control over the player one sprite. It looks cool so far. The only think I'm having problems is the frame rate, I turned the Backsave feature off and I get better rate. How can I keep this feature off and clean the screen like I read in other post. I couldnt understand how to do it.



- Just Me!
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 1st Jan 2005 04:10
I think I found it the CSL command help me achieve my last stated question, how to turn off the Backsave function and refresh the screen at the same time.

Here is the code


- Just Me!
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 1st Jan 2005 04:12
this might help your transparent black problem, not sure though:

_____________________________________________________________

SET IMAGE COLORKEY
This command will set the general colorkey for all images. A colorkey allows you
to specify a particular RGB colour that will be treated as transparent by the image
when used. Transparent pixels of an image are not drawn. You must use this
command before loading or grabbing an image in order that a suitable alpha map
be generated from the transparent pixels of the desired image to be calculated.
The alpha map is then used to decide which pixels are drawn and which pixels are
never rendered.

SYNTAX
SET IMAGE COLORKEY Red Value, Green Value, Blue Value
_______________________________________________________________

The Uknown Element Gaming Group
http://www.freewebs.com/tuegames/home.htm
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 1st Jan 2005 04:31 Edited at: 1st Jan 2005 04:33
Thank you for your response Shadowed Lightning! I will look to play with that feature a little bit more.

Game Update: I added a scrolling Background, it goes really fast, like these guys are playing in some sort of tunnel.

Now How can I start the colision codding? What showld I have in mind?



- Just Me!
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 1st Jan 2005 04:38 Edited at: 1st Jan 2005 04:43
I'll try to help you with that in a while, right now i have to go
just a little tip for the collision coding-

if the ball/disc reachs the x position of the player, then change the x velocity and angle of the ball/disc

NukeSoft Game Makers Team
http://www.geocities.com/nukesoft0
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 1st Jan 2005 11:45
Its cool man help me whenever you have a chance

Game Update: I added a better scrolling background, using the same plane twice instead of using a huge background. Also learned cool things about functions, like I can pass parameters from my main loop to the function



- Just Me!
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 1st Jan 2005 12:42 Edited at: 1st Jan 2005 12:52
Can I call a function from another function? and have all the variables updated at the same time?

I'm trying to create a function tpo track the X's and Y's from all the objects in the scene, that way I can just reffer to that function everytime I need X and Y, is this good?

Something like this


- Just Me!
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 1st Jan 2005 19:29
Not too good with functions, but you need a result from the functions to pass the variables out of it back into the main body of code (I think).

Am I the only one here who's really confused?
http://db1games.topcities.com
(used to be demonsbreath)
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 2nd Jan 2005 01:39
All my efforts are in vain, this code doesn't work... the function call is not pasing the variables as I thought it was going to happen...

Here have a look.


- Just Me!
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 2nd Jan 2005 08:33
How can I pass the variables from my function named SetInitialSpeedVariables(PlayerOneSpeedUp,PlayerOneSpeedDown,PlayerOneSpeedLeft,PlayerOneSpeedRight)

I thought by adding the parameter that was going to fix the problem, but it doesn't...



- Just Me!
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 2nd Jan 2005 13:37 Edited at: 2nd Jan 2005 13:42
ok here is what I got so far


Now the problem I have is that I cannot use my variables inside the array inside the function, even though I declared the array at the top of the program



What I want to do is have my speed related variables in one function. This function popullates the array that I have created at the begining of my program. And later on in the main loop I need the value of speed to be out of this array and out of this function, but I dont seem to understand the logic. I have gotten so far ahead of myself, by reading a lot of stuff here at the forum, but I think I'm somehow confussed or I am missing something in my code.

Here is the actual function()


Thanks!

- Just Me!
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 2nd Jan 2005 14:01
Got it fixed

The problem was that I wasn't adding the needed parameter for my PlayerOneMovement() since I changed to an array, now I have to use InitialSpeedArray(1,1), etc... instead of the old names I had before...

- Just Me!
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 2nd Jan 2005 19:24 Edited at: 2nd Jan 2005 19:32
This is what I got so far with my code. I place the sprites on screen, set some variables to start the game, and have some weird bouncing feedback from the disk. My collision system is weak, as for this is my first try I'm very please that I have been able to experiment with all sort of things, to try to make this little game. I added a picture of the lates development. have a look.

I will add the center screen collision soon.

I'm using GOSUB to do some things and functions() to do others.
that way I fixed my last problem, since nobody replied to my last messages.

If anybody is reading this thank you for rading it. Tell me what you think so far. I know the code is huge for so little that I have done, but thats the way it came out. I use many remarks in my code because I do so many things daily that I forget stuff really fast and easy, thats the reason I have so many remarks. also the same reason applys to the spaces in between lines, I cannot stand having the code all crammped up.



- Just Me!

Attachments

Login to view attachments
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 2nd Jan 2005 20:00
It looks pretty good from the picture - did you make those graphics yourself or did you just download/copy them?

Am I the only one here who's really confused?
http://db1games.topcities.com
(used to be demonsbreath)
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 3rd Jan 2005 01:30 Edited at: 3rd Jan 2005 01:32
Hello there demons breath, I created the graphics myself. thank you for stopping by

EDIT: Update; the disk gains speed while traveling in space, and also bounce (not correctly) but is bouncing when hit stuff around YAY!

- Just Me!
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 3rd Jan 2005 01:43
nice, how did you make those graphics?

NukeSoft
http://www.geocities.com/nukesoft0
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 3rd Jan 2005 02:06
I created the graphics Using Photoshop 7.0

- The game Window size will be 1024 x 768
- The Background is a 1024 x 768 .jpg
- The Other Sprites are .PNG (I have to retouch them a little there still some white pixel in the transparent areas)

Thants about it... My favorite 2D graphic tool is Photoshop if I don't want the picture to look very... cartoon network like cartoons... you know, like ... when I use vector (flash) I also use maya to do some other stuff. Once I'm done with my pong game then I will retro something from the mid 80's and if I'm ready then I will start using 3D.

Hope this answer your question.

PS: I will add some more stuff to the composition/stage and maybe you can choose a color for the player one - I have that in mind. but first the pong game, then customize it so it is a pong game but with more stuff to play with.

- Just Me!
Carolina South
19
Years of Service
User Offline
Joined: 28th Sep 2004
Location: South Carolina
Posted: 4th Jan 2005 03:36
Good job there ArsA. You're on your way to a great looking game.

If you like, you can take a peek at my source code (second post down) in this link here: [href]http://forum.thegamecreators.com/?m=forum_view&t=45133&b=5&p=0
[/href]

It might help you some.

"Diplomacy is the art of saying 'Nice doggie' until you can find a rock." - Will Rogers

"The secret to creativity is knowing how to hide your sources." - Albert Einstein
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 4th Jan 2005 10:15 Edited at: 4th Jan 2005 10:19
Carolina South, Thanks for your response and the link. I read the code, but is somehow too advance for me

I'm kinda of new to game programming, and I'm having a hard time with the bouncing the ball thing. I can make it bounce, but is weird looking. The biggest problem I'm having is the angle of the ball (disk) I dont know how to create that code... Here I will show what I got, is probably wrong, but here it goes


- Just Me!
Carolina South
19
Years of Service
User Offline
Joined: 28th Sep 2004
Location: South Carolina
Posted: 5th Jan 2005 02:52 Edited at: 5th Jan 2005 02:55
Your Disc should only be traveling in any one of eight(8) different directions. It can have 8 states of being. U, D, L, R, UL, UR, DL or DR. My version of the game only uses UL, UR, DL & DR. I exclude U,D,L & R as options so my Disc is always on an angle.

Depending on which of these it is, when a collision occurs, is how you would increment or decrement the x,y values of your Disc.

A collision with something (Wall, Block, Paddle) will change the state of the Disc's travel. If the disc was going Up & Left and it hit the top of the screen, then its new direction would be Down & Left. If it next collided with the left side of the screen, its new direction would be Down & Right. Works the same for the paddles * blocks/obstacles in your version.

Hope that helps some.

"Diplomacy is the art of saying 'Nice doggie' until you can find a rock." - Will Rogers

"The secret to creativity is knowing how to hide your sources." - Albert Einstein
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 6th Jan 2005 12:05
Awesome input you offered there Carolina South, it sure will help me alot. Thanks.

- Just Me!
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 7th Jan 2005 12:59 Edited at: 7th Jan 2005 12:59
Here is the latest update for the source code and the screen shot. The interface looks too dark, I might add some more color to it, I'm not sure yet. Also the controls doesnt work, at the moment is just a placeholder image. There is a picture update.



- Just Me!

Attachments

Login to view attachments
Neofish
20
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 8th Jan 2005 04:19
Quote: "Now the problem I have is that I cannot use my variables inside the array inside the function, even though I declared the array at the top of the program"

Arrays are global, which means they can be used any where. Normal variables are not so use the global command (global varName) to make them so.

ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 9th Jan 2005 14:00 Edited at: 9th Jan 2005 14:09
well, here is the latest of the source code and the actual game!!! is not 100% finished but is playable

- remember this is my first try -

source code here:

Direct Download:
http://www.arsa-studio.com/darkbasicpro/phong2d.rar

- Just Me!
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 11th Jan 2005 08:49
I'm waiting for more testers...

- Just Me!
Neofish
20
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 12th Jan 2005 00:37
It's very good but two points: the ball is too slow, the ball bounces incorrectly every so often

The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 12th Jan 2005 04:18
I like it but you can still do some more improvements.

Here is someone of them:

WE NEED BEATABLE AI!!!

a Menu would be nice

The ball bounces is buggy.


Just some of my thoughts but keep up the good work!


The Nerd


looking for Royalty free 3D objects?
then Check PanzerGames at this link : http://www.freewebs.com/panzergames
Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 13th Jan 2005 03:20 Edited at: 13th Jan 2005 03:31
Hey ArsA, very nice start, good artwork and fine music. I didnt have a problem with the ball speed, but it was a little disheartening only gettin one goal against the computer but yeah very nice, only thing i would say to change asap is the juddering when the paddals hit the screen borders.
If you want i can knock up a short vector routine to handle the bouncing off the paddals?
Good Luck

<Edit>
Is the ball bouncing buggy? i looked at the source code and from the looks of it the direction it leaves is random so yeah sometimes the disk goes up when you expect down. is that what you wanted Arsa?
ArsA
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Virginia, USA
Posted: 14th Jan 2005 02:58
Good many replies Thank you all.

BEATABLE AI - I'm working on this next
MENU - where? like at the begining of the game or something?

Baggers - thanks for your reply. regarding your question "Is the ball bouncing buggy?" I really wanted a realistic way of bouncing, but I cannot manage to create one. This is my first try, so I'm trying to come up with something nice. I'm not a programmer I'm an artist, but I have some programming knowledge I guess. But end of the line, I dont know how to make the ball bounce correctly I guess. I thought the ball was supposed to bounce randomly.

And the problem with the paddle when it hit the borders, it fixed already, is not suposed to bounce at all.

Thanks

- Just Me!

Login to post a reply

Server time is: 2024-09-23 09:31:27
Your offset time is: 2024-09-23 09:31:27