| | |
Cricket game :help needed
![]() |
•
•
Join Date: Jul 2007
Posts: 1
Reputation:
Solved Threads: 0
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...
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.
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 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.
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.
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.
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
![]() |
Similar Threads
- Game developers needed! (Software Development Job Offers)
- What online games do you play? (Geeks' Lounge)
- Quiz Time folks ....Lets test out your wit (Geeks' Lounge)
- Programmers needed for game dev. team (Software Development Job Offers)
Other Threads in the C Forum
- Previous Thread: .exe
- Next Thread: need help in C
| Thread Tools | Search this Thread |
* ansi api array arrays bash binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile createcopyoffile createprocess() csyntax directory dynamic fflush file floatingpointvalidation fork forloop frequency function getlasterror getlogicaldrivestrin givemetehcodez graphics gtkgcurlcompiling gtkwinlinux hardware highest histogram homework i/o ide inches initialization intmain() iso km license linked linkedlist linux linuxsegmentationfault list logical_drives looping loopinsideloop. lowest match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat openwebfoundation pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string suggestions test unix urboc user variable whythiscodecausesegmentationfault win32api windows.h windowsapi






