Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Pong Example #14

Closed
JohnDog3112 opened this issue Aug 20, 2024 · 8 comments · Fixed by #23, #37, #41, #43 or #53
Closed

Improve Pong Example #14

JohnDog3112 opened this issue Aug 20, 2024 · 8 comments · Fixed by #23, #37, #41, #43 or #53
Assignees
Labels
enhancement New feature or request

Comments

@JohnDog3112
Copy link
Collaborator

  • Remove any code that was only there for testing new d2d functions
  • Make a standard 2 player Pong with a computer opponent
  • Add sound effects as the AudioLibrary gets programmed
  • Possibly add better physics like having paddle velocity affect the pong velocity
@JohnDog3112 JohnDog3112 added the enhancement New feature or request label Aug 20, 2024
@JohnDog3112 JohnDog3112 self-assigned this Aug 20, 2024
@twiddlingbits
Copy link
Owner

image

@JohnDog3112 JohnDog3112 linked a pull request Sep 17, 2024 that will close this issue
@twiddlingbits
Copy link
Owner

twiddlingbits commented Sep 18, 2024

The new pong update is awesome!

On the 2 player pong, I have these suggestions:

  1. Give the user instructions on what keys to use (i wasn't sure how to be player 2)
  2. When the ball goes out of bound, before starting the new ball, give the user some kind of message. See the original pong for what it did/said.
  3. For bonus points: add support for a joystick or paddle control (this is more interesting in that you would add the event type to jsEventsLib
  4. For bonus points (not sure its worth the effort): The original pong drew the score numbers out of graphics segments. You are using a font. Pong purists will enjoy seeing an exact replica of the original game.

@twiddlingbits
Copy link
Owner

I also noticed this warning in the console:

twrWasmModule does not require shared Memory. Okay to remove wasm-ld --shared-memory --no-check-features

@JohnDog3112 JohnDog3112 linked a pull request Sep 21, 2024 that will close this issue
@twiddlingbits
Copy link
Owner

Audio is intermittent on Windows/Chrome. I noted this in the audio issue.

@twiddlingbits twiddlingbits added this to the 2.5.0 milestone Sep 24, 2024
@JohnDog3112 JohnDog3112 linked a pull request Sep 26, 2024 that will close this issue
@twiddlingbits twiddlingbits removed this from the 2.5.0 milestone Sep 27, 2024
@twiddlingbits
Copy link
Owner

i am leaving this open for the following:

  1. Give the user instructions on what keys to use (i wasn't sure how to be player 2)
  2. When the ball goes out of bound, before starting the new ball, give the user some kind of message. See the original pong for what it did/said.

But i am removing the must complete by milestone.

@JohnDog3112
Copy link
Collaborator Author

JohnDog3112 commented Sep 28, 2024

  1. Give the user instructions on what keys to use (i wasn't sure how to be player 2)

For now, I've added a text box below the game canvas that gives instructions on what controls to use. I'm also considering making a short start screen that will display the controls as well so it's more obvious.

  1. When the ball goes out of bound, before starting the new ball, give the user some kind of message. See the original pong for what it did/said.

I'm looking at the Atari version of Pong and I don't see any message. The only difference I see is a slight delay until the ball spawns again.

Also, in the vein of displaying messages, I have been creating a class for centering text. When I did this, I moved a LinkedList generic class/struct over to extra.h which is shared between all of the pong files. However, I keep getting linking issues with it. Do you know what might be causing these?

clang -c -Wall -O3 --target=wasm32 -nostdinc -nostdlib -isystem  ../../include -I ../twr-cpp  ../twr-cpp/canvas.cpp -o out/canvas.o
clang -c -Wall -O3 --target=wasm32 -nostdinc -nostdlib -isystem  ../../include -I ../twr-cpp  entry-point.cpp -o out/entry-point.o
clang -c -Wall -O3 --target=wasm32 -nostdinc -nostdlib -isystem  ../../include -I ../twr-cpp  pong.cpp -o out/pong.o
clang -c -Wall -O3 --target=wasm32 -nostdinc -nostdlib -isystem  ../../include -I ../twr-cpp  two-player-pong.cpp -o out/two-player-pong.o
clang -c -Wall -O3 --target=wasm32 -nostdinc -nostdlib -isystem  ../../include -I ../twr-cpp  extra.cpp -o out/extra.o
wasm-ld  out/pong-menu.o  out/canvas.o  out/entry-point.o  out/pong.o  out/two-player-pong.o  out/extra.o ../../lib-c/twr.a -o entry-point.wasm \
        --no-entry --initial-memory=2031616 --max-memory=2031616
wasm-ld: error: out/pong-menu.o: undefined symbol: LinkedListRoot<MenuButton>::LinkedListRoot()
wasm-ld: error: out/pong-menu.o: undefined symbol: LinkedListRoot<MenuButton>::addNode(MenuButton)
wasm-ld: error: out/pong-menu.o: undefined symbol: LinkedListRoot<MenuButton>::addNode(MenuButton)
wasm-ld: error: out/pong-menu.o: undefined symbol: LinkedListRoot<MenuButton>::addNode(MenuButton)
make: *** [Makefile:38: entry-point.wasm] Error 1

@JohnDog3112 JohnDog3112 linked a pull request Sep 28, 2024 that will close this issue
@twiddlingbits
Copy link
Owner

I'm also considering making a short start screen

That seems like the way to go.

I'm looking at the Atari version of Pong and I don't see any message.

Ok. I am not that familiar with the original Pong. But if you are doing what it does, then that's good.

However, I keep getting linking issues with it. Do you know what might be causing these?

chatGPT says: https://chatgpt.com/share/66f9d97d-481c-800a-9372-c31f27465483

Here is what I wrote before I aske chatGPT, but I haven't really used templates in c++ (i do use them in typescript):

If you show me the code (commit it, or provide a link, or whatever), i can take a look.
But I will say that in the past whenever I have tried to put actual code in a .h file it has never ended well and I always end up putting it in a .cpp file (and the class detentions in a .h file, like canvas.cpp). When it's in the .h, then you end up with name collision (same name compiled into multiple .o). I think you can work around it with appropriate use of inline, but that seems to be very fragile and confusing. I gave up getting it to work the one time i tried recently. You could make the code static, which might avoid the collision. But then you still have multiple copies of the same code, which doesn't seem clean, and there are probably other issues.

@twiddlingbits
Copy link
Owner

seems like this is fixed now. Please close if you agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment