Posted: Thu Dec 06, 2007 10:53 pm Post subject: Matrix Pong
I got borad so i decied to make a litte pong game as it seems to be so popualr to do in turing thess days.
I partly made this to be an easy template to edit for diffrent kinds of poing games, the idea is that i break pong down in to the basic produceurs you need (or basic conspects even). It is posible to break it down to more, like spearting the score system in to it's own procuedre.
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Sponsor Sponsor
Nick
Posted: Fri Dec 07, 2007 8:26 am Post subject: Re: Matrix Pong
lol Dan you beat me to it
Dan @ Thu Dec 06, 2007 10:53 pm wrote:
procedure cheapAI
you can say that again you cant win!!!
Dan
Posted: Fri Dec 07, 2007 12:44 pm Post subject: RE:Matrix Pong
The paddel is the one. How can you beat neo at pong?
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Zampano
Posted: Fri Dec 07, 2007 1:06 pm Post subject: Re: Matrix Pong
Lol, I guess the paddle found the true meaning of life at 42!
Dan
Posted: Fri Dec 07, 2007 1:28 pm Post subject: RE:Matrix Pong
Acuacatly, "Following this, the pong paddle went on a mission to destroy Atari headquarters and, due to a mixup, found himself inside the game The Matrix Reloaded. Boy, was THAT ever hard to explain to him."
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Nick
Posted: Fri Dec 07, 2007 3:18 pm Post subject: RE:Matrix Pong
you should add in that to the game (you play as the paddle in a first person shooter much like the matrix)
Dan
Posted: Fri Dec 07, 2007 7:34 pm Post subject: RE:Matrix Pong
If i ever had alot of free time i might aucatly do somthing in opengl about it. However i never have free time
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
MihaiG
Posted: Fri Dec 07, 2007 8:10 pm Post subject: Re: Matrix Pong
theres a sweet spot for the paddle, if u leave it there, and you can walk away from the computer and not loose
Sponsor Sponsor
petree08
Posted: Wed Dec 12, 2007 1:24 pm Post subject: RE:Matrix Pong
I think compsci should have a thread dedicated just to old game remakes because we have so many "pong , pacman , space invader ect" posts (not that this is a bad thing) it could leave the main submission thread for more "new" stuff
Dan
Posted: Wed Dec 12, 2007 1:28 pm Post subject: Re: RE:Matrix Pong
petree08 @ 12th December 2007, 1:24 pm wrote:
i like your code , i might have but my procedures above the vars for modularity sake
You put your golbal variables below your procedures? I don't see that much, persoanly i perfure the other way around.
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
LaZ3R
Posted: Wed Dec 12, 2007 10:54 pm Post subject: RE:Matrix Pong
I agree with Dan... I've always kept my global variables at the top of the program :p
I don't see why you guys write out the full "procedure' instead of just putting "proc"
Saves a few characters on each proc !
Tony
Posted: Thu Dec 13, 2007 1:24 am Post subject: Re: RE:Matrix Pong
Posted: Mon Dec 17, 2007 8:47 pm Post subject: RE:Matrix Pong
well i my self put globals above procedures when i'm using globals. but i noticed that in your procedures there are no parameters to them. this almost deafets the purpose of wirting a procedure to begin with. i see that it makes the code easier to read and debugging is easy. but it also makes a procedure "limited" to the program it was written for.
Code is much more recyleable(sorry for the spelling) with parameters .
there are huge arguments between globals and parameters and both sides have very good points but on big projects i tend not to use globals. but on random compsci games that i post i tend to use the above style. (if i use procedures at all)
any who thought i'd just put my points in
- happy coding
Dan
Posted: Mon Dec 17, 2007 10:13 pm Post subject: Re: RE:Matrix Pong
petree08 @ 17th December 2007, 8:47 pm wrote:
well i my self put globals above procedures when i'm using globals. but i noticed that in your procedures there are no parameters to them. this almost deafets the purpose of wirting a procedure to begin with. i see that it makes the code easier to read and debugging is easy. but it also makes a procedure "limited" to the program it was written for.
Code is much more recyleable(sorry for the spelling) with parameters .
You cleary missed the hole point of program on all levels.....
petree08 @ 17th December 2007, 8:47 pm wrote:
there are huge arguments between globals and parameters and both sides have very good points but on big projects i tend not to use globals. but on random compsci games that i post i tend to use the above style. (if i use procedures at all)
Ummmm, no. There is almost no debate about when to use globals or not and it is almost allways langue spefic to there aproite use. (tho i guses there are arugments about should you fallow what the langue dictakes or not)
If had read the text i posted with the game you whould know that:
1. It is a template for pong games witch means i intentaly whonted to break pong down it in to it's most basic compoents and divied them in to the most simple procedure posible. Fallowing this logic, golbals are a good idea as it cleary states the starting point of every values and expains there intention cleary. If i had made everything a paramter to procedure the complexity of the code whould be much higher and it whould be harder for peoleop to edit this a template to make there own pong game. Shure i could have made a new set of golabal varibles for the starting value of each paramter but then we whould be back where we started.
2. This is ment to be a joke, if you run the pong game you whould see why.
3. If i whonted i could have made everything a paramter and had no variables at all just to make it like funcaitional programing in turing, but there was no reason to do that for the above 2 points. At the time i was working on a OpenGL porject in pure C and this was done as a break based on a XKCD comic.
Now about golbals in turing in general. Due to the way turing is set up, when you are not using clases or moduels you almost have to use a globals some where in your code unless you are going to wrap things in a main function witch aucatl goses agisted the hole idea of symplisticy that turing is based on (and is totaly unessary). As for procedures being reused in other programs, that is not realy the point of procedures as much as it is of clases or modules. It is very rare you can just copy over a procedure with paramters or not and have it useable in another program unless that program is exteramly simualr to the one it came from. For example this pong program weather there was paramters or not the procedures could not be used in another program unless it was another pong game. Now in langues that do force a main method or class of some kind on the programmer (witch is both good and bad) the improetnce of globals is increased as there aucatly is a diffrence btween the scope of a vaibale in the main logic (the main method) and at the top of the code. However in turing there is no diffrence in scope if i declair the vaible at the top or just above the main loop (deacaring it in the loop whould be a bad idea as it whould be redecleared each interation of the loop). Now if i had gone the class, modeual way for pong then i whould not have used globals but i probly whould have had varaibles with class scope, class scope varibles witch are basicly golbals just for a class are comuany usesd rather then having the programer pass the paramters as it whould not make sence as the class whould all ready have that value and you whould be passing somthing like myClass.myMethod(myClass.myVar) rather then just myClass.myMethod(). (Note that myClass.myVar whould likey be the only resonable input to that method any how). So in my option when it comes to turing and you are not using other clases or moudles then you might as well treat it like the hole program is one class and the contrsutcer and driver of the class is the part not in a method. Also if we are to go by the offical turing documeation and expamles provied by holt soft this methodogly/way of thinkg is also comonaly used.
So in summary, you sould not try to force one langue to be another when you program in it (like trying to make turing like C by wraping things in main methods or make everything a class like java) but stay with the style, gudie lines and ideolgoy of that langue. Shure you could probly make a working program using idegolgoys of other langues but you will be fighting the langue you are using the hole way threw and in the end you probly will end up with exteramly hard to understand code that is not that efffshent becues the langue was not optmized to that idelogigy to beging with.
P.S. This is why i don't post code >_>
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Dan
Posted: Tue Dec 18, 2007 12:14 am Post subject: Re: Matrix Pong
Just for petree08 and ultrahex here is needless complexed recureisve pong:
Right now it is cheapAI vs cheapAI but you could "easly" modify (don't know why you whould) to have a humman player. Becues this is rescurive for no reason it will eventualy overflow the stack and crash.
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!