Cricket game :help needed

Reply

Join Date: Jul 2007
Posts: 1
Reputation: chota is an unknown quantity at this point 
Solved Threads: 0
chota chota is offline Offline
Newbie Poster

Cricket game :help needed

 
0
  #1
Jul 12th, 2007
hi guys i am new to this site...hope you all will provide me the required information....

here is what i wanted to ask....

i created a cricket game in C using some basic graphics functions....

what i did is i created some frames of bowler -bowling & batsman batting...
first i ask to press enter then the frames runs in motion ...& the score increases...
as you noted that it does not take the input for the movement of bat of the batsman...

so i want my game to be like this...
the input from the batsman should be simultaneously read while my bowler bowls.....
i.e; my program should be as efficient that it should be ready to take my batsman's input & parallely make my bowler bowl...

i call this process as parallel programming...
so pls do help me out...& make my game a successful one....

thanx in advance.
Last edited by chota; Jul 12th, 2007 at 10:04 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Cricket game :help needed

 
0
  #2
Jul 12th, 2007
Which graphics are you using.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,652
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 722
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Cricket game :help needed

 
0
  #3
Jul 12th, 2007
>thanx in advance.
For what? You didn't ask a question. You totally overused periods, but I don't see a question mark anywhere in your post.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 170
Reputation: TkTkorrovi is on a distinguished road 
Solved Threads: 11
TkTkorrovi's Avatar
TkTkorrovi TkTkorrovi is offline Offline
Junior Poster

Re: Cricket game :help needed

 
0
  #4
Jul 12th, 2007
What you talk about is not called "parallel programming" but event-driven programming. Event-driven programming is common for graphical programs which use widgets and windows. I wrote a snippet using GTK http://www.daniweb.com/code/snippet737.html where you can see how the event-driven program works. You can use GTK drawing area if you like, but the general principles are the same. There, in the end of the function main, is a loop that is called a "game loop", which is for anything that has to happen all the time continuously. But you see that the special functions shall be registered for events, such as key press, delete and destroy. These functions are called the event handlers, so that when some event happens, the function which handles that event would be called, while the main loop would go ahead as if nothing happened.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 170
Reputation: TkTkorrovi is on a distinguished road 
Solved Threads: 11
TkTkorrovi's Avatar
TkTkorrovi TkTkorrovi is offline Offline
Junior Poster

Re: Cricket game :help needed

 
0
  #5
Aug 7th, 2007
I'm sorry for replying so late, but i couldn't explain more before, because there were not much programming examples for such graphics games. Now i made one and posted here in snippets, a GTK version of the original xasteroids (which was written with xlib) http://www.daniweb.com/code/snippet744.html

In addition to keyboard input etc, you see there, that a frame is prepared in every game loop, and then the expose event would be ordered to write the frame on window. The frame is made in pixbuf, which is nothing else than a picture in memory, the pixbufs can be copied into each other, modified in various ways, and loaded from image files of different formats, or embedded into the code as strings. There is also a thorough collision and bouncing implemented, this could though be a simpler one for the round objects such as asteroids, but it could be good for the objects with less round shape, so maybe that too would be useful for you when writing a cricket game, or for anyone who wants to write a similar game.

As i said earlier, GTK is a good thing to use, if you are not going to write 3d games, because GTK is free, not anyhow commercial, and truly cross-platform, and it's useful to learn it because it is also a good api to write graphical user interfaces, such as various dialog boxes and menus, the gnome desktop and many other important applications were made with it. Therefore i think that GTK is the best graphical api for these who learn c programming. Some say that GTK is slow for games, but such opinions must only be based on some superficial knowledge about GTK. Why one may claim that GTK is slow, is because GTK has to deal with so many things, such as menus and dialog boxes, it certainly spends more time in every loop for processing these things. But say that you want to make 20 frames in a second in game, then very insignificant percentage of time would be spent for system processing, and drawing the picture in memory is not anyhow slower than with any other graphics api.
Last edited by TkTkorrovi; Aug 7th, 2007 at 12:34 pm.
Knowledge is regarded by the fool as ignorance, and the things that are profitable are to him hurtful. He liveth in death. -- Thoth the Atlantean
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC