I've created my first graphical C/ASM program ever: Pong 2.0. Not the basic PONG, with paddles left and right, but also at the top and the bottom. Your task is to keep the ball in the field.


It is yet not bugless, and the ball/paddles are going to hard, but I'm working on that Smile

(The gif is a bit buggy)
Looks good so far, PT_! You mentioned on SAX that you had a question about slowing it down. I recommend something like the following pseudocode:


Code:
uint8_t ticks = 0;
bool running = true;
do {
    int key = getkey();
    if (key == kQuit) {
        running = false;
    }
    if (ticks % 8 == 0) {
        if (key == kDown || key == kLeft || ...) {
            // Move paddles
        }
        erase_ball();
        move_ball();
        draw_ball();
    }
    ticks++;
} while(running);
This gives you a running counter that checks the keyboard on every iteration, giving you a quick way to quit and letting you spend some time in each loop. On every 8th loop, it gives you the option to move the paddles, and also moves the ball. An even better design would use the crystal timers, to make the ball's speed constant regardless of how much drawing or paddle movement is going on, but as I said on SAX, I don't know if the crystal timers have been exposed in a C library yet.
Nice work PT_! Looks like a fun game Smile I think the gif may be off because you are only recording every third frame, which is the default. There's an option to change that. Anywho; The timers are another library in progress... Yay. Anywho, the graphics library is kind of changing a bit to make it easier to use tonight, so hopefully that will be helpful. Good luck! Smile
Thanks to both Mateo and Kerm, who helped me over SAX, I've completed the paddle movement. I got rid of the switch, and use only 1 if-statement Smile
Now I have a better gif for you guys!


As you can see, at the end of the gif, it's impossible to survive. I will generate a random starting X-value to 'prevent' this. Now I'm going to work on win-checking.
Awesome work PT_! Looking pretty spiffy indeed Smile And now I am sorry, but you have to reinstall the graphics libraries Sad There were quite a few bug fixes and optimizations that should greatly benefit you, in addition to the inclusion of a string and character width functions. Hope this helps; and I removed the ability to set the color of a rectangle, line inside a function. Now you can just use gc_SetColorIndex() in order to select the global color. This makes it a lot faster and easier to use. Anyway, great job so far, and I can't wait to see what else you add! Smile
MateoConLechuga wrote:
Awesome work PT_! Looking pretty spiffy indeed Smile And now I am sorry, but you have to reinstall the graphics libraries Sad There were quite a few bug fixes and optimizations that should greatly benefit you, in addition to the inclusion of a string and character width functions. Hope this helps; and I removed the ability to set the color of a rectangle, line inside a function. Now you can just use gc_SetColorIndex() in order to select the global color. This makes it a lot faster and easier to use. Anyway, great job so far, and I can't wait to see what else you add! Smile

Thanks Very Happy
I've updated the libraries, and with almost the same code, I saved over 100 bytes. Amazing! Smile
I will upload this version to the Archives, maybe I will make later another, more advanced version.
I've made v2.2 (not uploaded yet) where the ball starts random.
Ooh, and I'm gonna change that you move with both the horizontal and vertical paddles. With that, it is sometimes impossible to survive.
Download Pong 2.X
Here's an interesting idea:

1) Left Arrow: Top paddle left, bottom paddle right
2) Right Arrow: Top paddle right, bottom paddle left
3) Up Arrow: Left paddle up, right paddle down
4) Down Arrow: Left paddle down, right paddle up

Just an idea. Razz Good luck, and great work! Smile
MateoConLechuga wrote:
Here's an interesting idea:

1) Left Arrow: Top paddle left, bottom paddle right
2) Right Arrow: Top paddle right, bottom paddle left
3) Up Arrow: Left paddle up, right paddle down
4) Down Arrow: Left paddle down, right paddle up

Just an idea. Razz Good luck, and great work! Smile

I've implemented it, and it looks great, BUT YOU HAVE NO IDEA HOW HARD THIS IS TO PLAY!!! Smile Smile Very Happy

I will upload v2.3

EDIT: I somehow missed the gc_NoClipHorizLine. I can use that instead of gc_NoClipLine, which saves me 3 bytes each.
It should also be a lot faster, because it's just a memset, instead of having to mess around with calculating slope, etc.
I'm happy to say that I've uploaded v2.4, almost the last one. I've fixed some minor bugs, and changed the lay-out a bit. Once it's accepted, take a look at https://www.cemetech.net/programs/index.php?mode=file&path=/84pce/asm/games/PONG2.4.zip (not possible yet).
elfprince13 wrote:
It should also be a lot faster, because it's just a memset, instead of having to mess around with calculating slope, etc.

I'm not calculating the slope. I can make it so fast that it's impossible to play the game.
v2.5, the last and final one will be extremely fast and hard Wink
PT_ wrote:
elfprince13 wrote:
It should also be a lot faster, because it's just a memset, instead of having to mess around with calculating slope, etc.

I'm not calculating the slope. I can make it so fast that it's impossible to play the game.
v2.5, the last and final one will be extremely fast and hard Wink

The gc_NoClipLine has to calculate the slope of the line. gc_NoClipHorizLine is a lot faster, as it can just directly set the pixels. gc_NoClipVertLine is also a lot faster than gc_NoClipLine as well. Wink
As you may have experienced, version 2.4 in the Archives is broken - it resets your RAM. This is because of a bug in the libraries that will cause that (Mateo posted about it). He just said he fixed it, and will update the libraries within some hours. Please don't download Pong before that time Wink

Oh, and an art impression of the final version 2.5: you can set your own speed, and probably even more...

EDIT: everything has been fixed, and I've uploaded the right version of v2.4 to the Archives (not accepted yet)
I've started creating v2.5, the last and final one. As some of you may know, this would be more advanced, and even harder to play Smile I don't going to say too much of it, you will see it all once I uploaded it.

Here are some tasks on my to-do list:

  • Done Set the speed
  • Done Paddles not reversed
  • Done Add colors...
  • Add an Easter Egg (Kerm: I can do that too Wink)
  • Secrets...

I hope I can finish it tomorrow, or even today Very Happy
Final? What about scoring, title screen, a fancy HS table, and an about page?

EDIT:
I found a bug! I was bored and I messed around on the game, and found out that I'm a total master at this game. I also discovered how to change my speed. When I mastered the next 2 speeds to the point of boredom, I went up and couldn't move the paddles. I guess that die button isn't as useless as I thought.

Have you ever thought how cool this might be if it was combined with CMonster? But what I really want is for this to be finished off. Then I can start a tournament with my friend, who is the only ninja I know.
Dudeman313 wrote:
Final? What about scoring, title screen, a fancy HS table, and an about page?

EDIT:
I found a bug! I was bored and I messed around on the game, and found out that I'm a total master at this game. I also discovered how to change my speed. When I mastered the next 2 speeds to the point of boredom, I went up and couldn't move the paddles. I guess that die button isn't as useless as I thought.

Have you ever thought how cool this might be if it was combined with CMonster? But what I really want is for this to be finished off. Then I can start a tournament with my friend, who is the only ninja I know.

~volunteers

I mean, I've created this program in my little free time. I'm very busy with life and school stuff, not too much time for programming. I'm happy with what it now is, and I will MAYBE bring v2.6 on the market, with some upgrades, like a highscore etc.
For your bug: I will look into that.
Yay! A 3D CMonster. Nope. Just not.
I can do the title screen for you, but I just don't know how to put it into the game.
If there are any restrictions as to what the title screen must look like, let me know.
Dudeman313 wrote:
I can do the title screen for you, but I just don't know how to put it into the game.
If there are any restrictions as to what the title screen must look like, let me know.

It is not that I can't make it.
I've yet not enough time for an impressive update. If I'm going to make a new version, I would like to make it myself. I appreciate your proposal, though.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement