-
Notifications
You must be signed in to change notification settings - Fork 31
Basic functional pong game #60
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
Conversation
manuq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You did Pong! So cool! I left a comment about the implementation but we can iterate after merging. Feel free to merge, my only request is to explain the changes in the commit message body.
| param_input.name = "ParameterInput%d" % start # Unique path | ||
| param_input.placeholder = param_name | ||
| if param_type: | ||
| if param_type != null: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
|
||
| var b = BLOCKS["statement_block"].instantiate() | ||
| b.block_format = "Set Physics Position {position: VECTOR2}" | ||
| b.statement = "PhysicsServer2D.body_set_state(get_rid(),PhysicsServer2D.BODY_STATE_TRANSFORM,Transform2D.IDENTITY.translated({position}))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why this is not needed in Moddable Pong.
I think because what we do for respawning the ball is (from memory):
- Duplicate the node
- Queue free the old one
- Set a random position to the new one, and finally call add_child
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think setting the position this way is fine too, since we don't have node instantiation yet. This seemed like the simplest way.
Also, we should add random blocks in the future! I remember using them very often in Scratch, and they introduced me to the world of procedural generation :)
| var parent_class: String | ||
| if found_simple_class_script: | ||
| parent_class = found_simple_class_script.get_base_class() | ||
| parent_class = str(found_simple_class_script.get_instance_base_type()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this change? What is this doing and why is it needed? Ideally in each commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was explained in #59.
| size = Vector2(128, 1080) | ||
|
|
||
| [node name="GoalArea" type="Area2D"] | ||
| collision_mask = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
Rebased to incorporate sound effects in the pong scene. Should we move it into an Note: It seems like the |
dbnicholson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it being in an examples directory in the plugin so that someone who installs the plugin can play with a fully formed game and see how the plugin is intended to be used.
Could you also add something to the commit message like @manuq requested? You can probably just copy in the text you put in the PR.
|
Sure, will do! |
Added scoring, and resetting the ball on score. Added a block for "Set Physics Position" which queries physics server, since "Set Position" does not work on RigidBody2D. Fixed small bug in StatementBlock where TYPE_NIL is technically equivalent to false, so it was being considered null.
The BlockCode scripts were out of date anyways, and the pong game is a better example.
dbnicholson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me. I was thinking maybe we should leave test_game as a complete playground, but I don't think there's a ton of benefit.
I thought it would be fun to take a stab at implementing a very basic version of the pong game to see what other blocks/improvements we would need to implement.
I added scoring, and resetting the ball on score. For resetting the ball, interestingly enough, setting the
positionof aRigidBodydoes not work like a normalNode2D, you have to query the physics server. So I added a block for "Set Physics Position", which honestly isn't very clear for a beginner.One thing I did find in making this is that we should think about making the variables more streamlined. Typing the variable name out every time is annoying without being able to copy blocks, and we should have a block for "Change variable by", so I don't have to use the "get variable" block every time.
I also found a small bug in
StatementBlockwhereTYPE_NILis technically equivalent tofalse, so it was being considered null.