I created a bouncing ball game in scratch for CS50 PSET0.
The game works well as I expected, except for the following bug/errors:
The game can be paused by pressing the UP Arrow key on the keyboard, even BEFORE it is started or AFTER the game is over. THIS SHOULD ONLY WORK WHEN A LEVEL HAS BEEN SELECTED AND GAME STARTED AND NOT BEFORE OR AFTER IT IS STARTED. [WORKING ON IT]
I set the Paddle dragmode to not draggable, yet it's not working as you can still drag the paddle using the mouse. [SOLVED]
Falling eggs/bomb won't stop falling when the game is over or paused. [TRYING TO SOLVE IT BROUGHT A NEW BUG] One egg appears at the bottom of the screen after I paused and resume the game. I'm not sure how to hide that one stubborn egg.
On hitting the paddle or edge, the ball bouncing isn't very smooth and natural. It sometimes lag. [WORKING ON IT]
JUST CURIOUS: Why is the code "when I receive Setting btn Clicked" not working on the sound and music button sprite? [SOLVED]
I will appreciate all your kind suggestions.
Here's my project
NB: if the question seems unclear and you tend to understand it. Kindly feel free to suggest an edit. Thanks.
For point 1, you could test with an if statement whether the game is currently running. (Using the same variable you use to pause the game.)
As for the dragging of the paddle, I can't seem to drag it. That is, I can't drag it when I am playing, but I can when in the editor. This is always the case, you can drag any sprite around while editing, but not when playing without the editor open. This is the default behaviour of sprites as well, you do not have to declare it each time. A reason for you to want to drag sprites is when you use the Pen Extension to create a drawing program.
To stop the eggs from falling, you could pause the clones the same way you pause the ball when moving.
To let the ball turn more smoothly you could let it turn between an angle from -90° to 90° opposite to the surface it hits. To implement this would be quite difficult with a single line. You could, if you don't mind it hitting the edge instead of the border you built, split it so you include the built-in block: if on edge, bounce. The if-statement would then only include the touching of the paddle (and maybe the danger bar). In this statement, you would select an angle between -90 and 90 degrees.
For 5, there must've gone something wrong when you wanted to design this, the when I receive [setting btn clicked v] block is just not connected. :)
Related
Im creating a small retro space invaders type game and wanted to hide the turtles being spawned in the background of the program while having a "loading" screen in front. is their any way to do this? (This is the first question i've asked on here so i'm not sure what code i need to include)
As a rule, turtles can never appear behind anything drawn by turtles. I recommend you put up your "loading" screen message, and create your turtles invisibly:
turtle_4 = Turtle(visible=False)
Then, when you're ready, take down your loading screen message and use showturtle() to make your fully configured and positioned turtles visible.
I have a simple shooter game where a gliding sprite is supposed to shatter (using mosaic effect) when hit, then disappear. Problem is, the sprite only shatters and disappears maybe 1 time out of 5. Here's the relevant code snippet:
For more context, here's the link:
https://scratch.mit.edu/projects/524150880
In the project, you're using set mosaic effect, not change mosaic effect. This makes it just do nothing and then hide.
I replied to your other question on this project
Maybe you have to increase the delay, if it is .25s it is just a quarter of a second and players may not be able to see it. Try extending it!
If that is not the reason then I don't know
It is a great library. It works well. Thank you Bumbu Alex and Anders Riutta and all the contributors. Well I got stuck. I have tried a lot. I guess the answer is nearby.
When I zoomIn by wheel or pinch (no matter) it zooms well in and out. When I reach zoom back by 1 it stays in place.
But when I
ZoomIn 2 times (for example)
Move my mouse cursor away (1 inch for
example)
ZoomOut all the way and my elements are all off. So nothing
centered anymore. It is applied a pan. Half elements are got cut off
of the viewport.
So it is not a bad. I guess I use it wrong. I have tried thousand times to resize it back but nothing works for me. I appreciate any help. Thank you.
It is normal behaviour as zooming with a mouse zooms based on current mouse position. Same goes about zooming out.
If you want to achieve zooming in and out that is always the same then you'd have to:
disable default mouse handing
add your own listener for mouse scroll events
when mouse scroll is fired - zoom in our out
(This demo) has some similar changes.
If you just want to centre the contents then you can use .center() or .contain() methods (you may also need to call .fit()).
I'a currently working on a small utility, it's my first ever X project. The utility is used to draw a small circle around your mouse pointer. I use an app called Pinpoint to do the same on my Mac, it helps me find my mouse as I'm visually impaired.
The utility creates an transparent X window and draw a circle inside, it then moves that window with the mouse pointer so that the circle follows the mouse.
It currently works, except for one detail. Mouse events are not propagated up to the underlying windows. Basically, the utility makes the mouse useless.
As far as I can tell from the Xlib docs, if not otherwise specified, new windows should propagate all events. How can I fix this?
The code can be found on GitHub: https://github.com/blubber/circle-cursor it's a bit messy currently, becaue it is just a proof of concept.
I would suggest doing via cursor image as well, there are many ways when you won't be able to receive mouse events and only possible source would be polling with XQueryPointer.
With xfixes extension you can subscribe to all cursor image changed events and get most recent shape of the cursor, and whit XRender you can set your own ( possibly animated cursor )
The game I'm designing currently requires a first person controller and luckily Three.js offers that class as well.
However I can't stop the camera from flying around. I know that the mouse movement causes the fly because it happens as soon as I move the mouse. But reading the js code,I cant find the attribue which causes this movement. Here is how I initiate the controls:
controls = new THREE.FirstPersonControls(camera);
controls.movementSpeed = 0.1;
controls.lookSpeed = 0.001;
controls.lookVertical = true;
I do not want the view direction to change when I am not moving the mouse.
any idea ?
Keep in mind that the FPS style mouse movement in webGL is usable rather only in a full screen mode. If an application runs in a standard windowed mode, the cursor is visible, and the application can not detect cursor movements that cross the edge of the window. This makes it impossible to look around in the FPS style (look movement stops when the cursors reaches the window edge).
This is probably the main reason why a PointerLockControls demo asks you to switch to the full screen mode.
With FirstPersonControls the look movement continues when the mouse reaches the edge. Such approach works well in the windowed mode.
You might want to use the PointerLockControls instead
See an example here:
https://github.com/mrdoob/three.js/blob/master/examples/misc_controls_pointerlock.html