I switched my interest towards writing a Text Based
pong game.
here's the code which I wrote so far :
This is the most basic code. (Just did 1 minute of work on this.)Code:#include <stdio.h>
class tag_ball
{
public:
int x, y;
int oldx, oldy;
} ball;
class tag_paddle
{
public:
int x, y
int oldx;
} paddle;
main()
{
}
I want to make this program as simple as possible (I wrote this
game in Qbasic, but in graphics, but didn't program it really
well. Now that C programs are structured, I want to make the code simple more readable.
Ok, here comes the question.
Whenever I say
paddle.x = 5
I want the paddle class' x variable to be 5. And I want it to
automatically call a function (say, placepaddle, or whatever name)
and run that function, how do I do that ?
in other words, whenever I set the variable, it should automatically call a function that does a particular job.
I know this could be done in classes (that's the reason
why I changed my struct to class), but I don't remember how.
CHECK OUT www.akilla.tk