Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

nitehawk

Sport game for Dummies :)

This topic is 5276 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Iam sorta new to games programming and I need some help on deciding few things. Iam thinking of developing a sports game. I think i ll use 2d rather than 3d using ta skills (or the lack of it) i got. Iam used to java but I know java is way slower compared to other languages like c++. Question 1 is what language should i use for this game? (i dont like C, so its out of the question java? c++? Question 2 is how do i manage timing of my game? What i mean is the movements of objects (ie a ball, a player) is controlled by the keyboard but how to make this movement smoooth and exact across all pcs that might run this game? Question 3 is can I design a proper user interface if i use java? how to do this? All help appreciated. PS: Excellent forum by the way. keep up good work [edited by - nitehawk on May 7, 2004 10:37:48 PM]

Share this post


Link to post
Share on other sites
Advertisement
Yes, Java does get out performed by many of the other programming languages, but that doesn''t mean its necessarily ''worse''. It really depends on the medium you want your game to be played through. The advantage to java is that doing a cross-platform game is possible with a single compile version of the game.

1) Well, if you don''t like C, you''re not going to like C++, because C++ is pretty much just an extension of the C language (of course, if it''s just C syntax you don''t like, you''d best go with something like Basic, because pretty much everything else uses C style syntax...)

2) You''ll have to include a timer function and have your motion based on math (i.e. distance = rate * time). The specifics of this will have to wait until you pick a language

3) You can do most anything you want with most any language, it really just depends on what you the programmer do with the tools in front of you.

Share this post


Link to post
Share on other sites
Thanks for your reply!

Well when i said i dont like C what i mean is, I dont like all the unneccessory coding required with C (defining Memory allocations, free'n up space)

However if im correct C++ takes care of this doesnt it? Plus C++ is more closely relates to Object Oriented programming style which I prefer (being a java person )

Say I pick java for implementing this game, How do I handle the moving of objects
As you said distance = rate * time
but how do i manage time in the program? Do i use threads or?

If I take the following example case....

Lets say I want to move the ball from a player to the opposition player. I know they are always 20m apart (this is the actual distance in real life), And i also know how fast the player can throw the ball (100km/h). so using your equation i know the distance and the rate hence i can find the time. But now what?
By knowing the time, how do I show the flight of the ball from player to opposition smoothly?

Please tell me how to do this in Java...and also using C++ if its easier than java hehe

Thankz zo much :D

[edited by - nitehawk on May 7, 2004 10:35:42 PM]

Share this post


Link to post
Share on other sites
quote:
However if im correct C++ takes care of this doesnt it? Plus C++ is more closely relates to Object Oriented programming style which I prefer (being a java person )



I recommend you to give a look on D, which has a garbage collector, which takes care of memory deallocation, is almost as fast as C++ and has about the same syntax, check it out here: http://www.digitalmars.com/d/

Note: If you want an IDE for D, i recommend you to search for DIDE in google. It''s a beta IDE but still better than nothing.

Share this post


Link to post
Share on other sites
Not being a java programmer, I don''t know the specifics of how you''d get the time in java, but I''d suggest googling for a java high resolution timer. Here''s the idea behind time based movement.

Each frame:

Time = Get time that has passed since last frame (should be in ms)

BallMoveDistance = Rate (scaled) * Time

Hope that sorta makes sense The keys to remember here is that the distance your figuring is how far it moved THIS FRAME and that the times will likely be in ms, so you''ll need to get your rate scaled appropriately. Hope that helps!

Share this post


Link to post
Share on other sites
This is a java question.

Does java provide good interface with the keyboard? (java 1.4?)

For instence, my game should support two players, so it might be the case that players will be going hard out at the keyboard, maybe pressing several keys at the same time

would it be possible to capture all the key events generated by the two players and process them correctly?

Please advice
Thankz in advance

Share this post


Link to post
Share on other sites
To quote my Computer Science lecturer; "D is probly the best language out there. Will it go anywhere outside of Uni''s? Probly not."

nitehawk, for the level of games you intend to make, especially considering they will be 2D, the speed of Java won''t be a real issue.

I''m in the process of writing a four player Snake game, all players using the same keyboard. So far I''ve had no problem catching key events.

Yes you can create proper interfaces in Java, but because the language is cross-compatable, expect some things to look different depending on what OS the program is run on.

Google for something like "Java Swing" for tutorials on that.

Instruo is right about the time based movement.

What''s more, don''t write your program so that "Pressing left moves your player left 5 pixils", you need something more like "Pressing left starts your character moving left, and continues to do so until left is released". Otherwise your movement will be based on how fast the keyboard/OS is firing key events.

Share this post


Link to post
Share on other sites
quote:

What''s more, don''t write your program so that "Pressing left moves your player left 5 pixils", you need something more like "Pressing left starts your character moving left, and continues to do so until left is released". Otherwise your movement will be based on how fast the keyboard/OS is firing key events.


Tanx , now i understand about moving 5 pixils each time key pressed. This is how i wrote one of my old programs (Frogger)

Only thing im worried about is would java fail if say, 4 keys are pressed at the exact same time. Hope it would recognise all 4 key strokes.

if(e.getKeyChar()==''A'')
startPlayer1Movements();
if(e.getKeyChar()==''B'')
startPlayer2Movements();
if(e.getKeyChar()==''C'')
startPlayer1Kicking();
etc etc...

would pressing "A" , "B" , and "C" at the sametime call all methods startPlayer1Movement(), startPlayer2Movement and startPlayer1Kicking()
without having stuff like synchronised methods and threads and so forth (which i hate )

Share this post


Link to post
Share on other sites
The easy way to find out would be to try it.

Write a simple program that outputs (i.e. System.out.println() each character that''s pressed.

Perhaps output the time (in milliseconds) it''s presed too, then start mashing the keyboard, and see if it looks like keys are being missed (make sure oyu are pressing them properly of course ).

You can get the current time with:

Date now = new Date();
long currentTime = now.getTime();

You will probly find you do need atleast one thread to make an animated game. Your main program can handle all the user input etc, and then your thread would just be a loop, calling for the game to be repainted, and anything else that needs to be done, such as incrementing timers etc, then sleeping a while, before looping again. Though it doesn''t have to be that way. A more simple game could just call to be repainted whenever it knows it will need to be.

Share this post


Link to post
Share on other sites
Have you considered BlitzBasic or DarkBasic? Don''t let the basic put you off they''re pretty powerful without a lot of the
"unneccessory coding".

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!