944,065 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2144
  • C RSS
Jul 12th, 2007
0

Cricket game :help needed

Expand Post »
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...

Quote ...
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chota is offline Offline
1 posts
since Jul 2007
Jul 12th, 2007
0

Re: Cricket game :help needed

Which graphics are you using.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Jul 12th, 2007
0

Re: Cricket game :help needed

>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.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Jul 12th, 2007
0

Re: Cricket game :help needed

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.
Reputation Points: 85
Solved Threads: 13
Junior Poster
TkTkorrovi is offline Offline
170 posts
since Mar 2005
Aug 7th, 2007
0

Re: Cricket game :help needed

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.
Reputation Points: 85
Solved Threads: 13
Junior Poster
TkTkorrovi is offline Offline
170 posts
since Mar 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: .exe
Next Thread in C Forum Timeline: need help in C





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC