Pushings Crates in GameMaker Studios 2 - game-maker-studio-2

I have tried adding this system into my game (https://www.youtube.com/watch?v=oorxWJMMSL0) but it doesn't work. My problem is that when I press P once (key I use for pushing crates) the box moves then it stops near the wall like it should but pressing P for the second time either pushes the crate into the wall or it goes thro the wall and after that I can't move it anymore
I have tried coding it myself and most of the tutorials I could find.

make it so when it touches the wall it moves back just a little bit so it basically stays at the same place.

Related

Pygame Trail Leaving

Alright so, i'm currently working on a big pygame project. I'm actually working on building a tank game, based on space invaders. The issue is(i mean it's not necessary, but whatever) that whenever my tank moves left or right, i want him to leave a certain trail. Now, the trail is an image of an actual tank trail, and i'd like to keep displaying that image after he moves left, right, down or up, exactly like he's leaving a trail;. The point is that i want my game to look very cool, and i think this is a big extra to that. I won't post my code since i just need general instructions on this topic, not a specific code clarification or something else.
Thank you all in advance, you're awesome! :D
P.S. Here's a trail image! I'm srr it's a link tho :(
https://i.stack.imgur.com/177IS.png
You would have to create an image for the tread marks and then load it using transparency/alpha. Then as you drive you would need to add those to a list with positions trailing the tank as it drove. You would need to keep the entire list of the trail and keep drawing it onto the background as you redraw the screen.
One thing to keep in mind is that if the tank drives back over them, you will not want them visible over the tank, so you will need to layers or just make sure that the tank is drawn last.

C++ SFML Frogger Sprite Movement

I am new to coding and currently making a C++ version of Frogger using SFML.
I want my frog to move like it does here: http://froggerclassic.appspot.com/
Currently I am using isKeyPressed to move my frog and it is moving in a smooth motion in any direction rather than jumping from position to position how I intend it to. How should I go about implementing this?
As often there are multiple solutions.
You can use events instead of real-time inputs. That way you can move once when a KeyPressed event happens and don't move until the KeyRelease event happens.
Alternatively, you can introduce a sort of cool down for your key. So when you detect a key press the first time you move the frog by X amount and staet the cooldown timer. As long as the timer isn't zero, you don't move the frog.
As timet you can use an sf::Clock and a sf::Time.

How to stop gamemaker object from leaving tracer

I have just started to use gamemaker and have made my first very basic game, it's just a circle that moves with the arrow keys.
My problem is that when it moves it leaves behind an image of itself in every space that it occupies.
All I have is $motion_set(0, 5);$ as the action.
Any help is much appreciated!
I am not really familiar with Studio 2 but in 1.4 your code causes my sprite to move across the screen without leaving anything behind. Are you sure there is nothing else in your code. It seems to be re-creating a new sprite either at the old location or creating a new object at the old location.
You can also you x += (the ammount of pixels you want to move) This works for x and y.
Thanks, Jonathan Greene

Unreal Engine 4: Character collider goes through floor when crouching

I'm using the 3rd person blueprint template and I've added a custom sprint and custom crouch functionality to it.. when crouching I trigger the crouching animations according to the character speed and set the max walk speed to a low value, I can interrupt the crouch by sprinting and vice versa... I can stand up from the crouch by pressing the crouch key again or attempting to jump.
It all worked quite well, until I attempted to manipulate the capsule collider's half height according to the character's speed whenever crouch, jump, or sprint is pressed... I can see the collider working as expected, however when I try to crouch the character's feet sink into the ground and when I try to stand up again the character falls through the floor...
Any help would be greatly appreciated...
The problem is that just shrinking the half-height is probably not what you want when your character is crouching, because your collision capsule is shrinking from the top and the bottom.
So, the feet of your character start to sink into the ground and when you grow your capsule it will clip through your level and fall down due to gravity.
You have two possibilities to fix this:
Use two capsules on your character, one for crouching and one for standing and only activate the one you are using
Move the capsule down the same time you are shinking it.
The capsule needs to finish at the same point, so move it lower.

How do you make computer lose in a pong game?

So me and my partner are trying to make a pong game that's player vs. computer, but we just couldn't figure out how to make the computer lose.
We already have the basic stuff done and it works fine but the computer just never loses. And we also tried slow down the computer peddle using sleep, but whenever the paddle moves slow, the ball also moves slow.
any advice would help!
Thanks
And we also tried slow down the
computer peddle using sleep, but
whenever the paddle moves slow, the
ball also moves slow.
You need to make it slower by moving it a shorter distance each time it moves.
In the original Pong game, the paddle was perfectly in sync with the ball, that is whenever the ball went down a line, the paddle did too. Obviously, that would make the game unwinnable so the solution used by the developers was to skip an update cycle every few cycles.
In layman's terms, on every frame, you adjust the paddle's location to follow the ball, except on the fifth, tenth, fifteenth, etc. By doing that, your paddle will seem to follw the ball nicely, but with some kind of delayed reaction.
I assume that the computer never loses because it "knows" where the ball is going to go. In that case, why can't you make it go to the wrong place some percentage of the time?
As well, if you just wanted to slow it down, rather than sleeping, you could intersperse "moves" of "don't go anywhere" along with the movement towards what it thinks is the right place to be. So instead of "down 1, down 1, down 1", you could have "down 1, down 0, down 0, down 1, down 0, down 0..." or something along those lines.
I think there is a game site for problems like this https://gamedev.stackexchange.com/. But my answer would be to try and cycle the top speed of the AI bat. And to make the bat short sited. (Only respond to the ball position once it is in its half.)
Computer must make mistakes to lose. The catch is, the mistake must be realistic. If the mistakes seems too artificial, the human player loses interest after a while. The human must believe the cause of the mistake is his good play.
The computer may occacionally react late. I mean, freezes when the human hit the ball. This may especially happen if the human hit the ball with the edges.
Intentional going slow would be unrealistic. But sometimes the computer may go a little bit slower while defending a ball that would bounce.
The computer may plain react to wrong side (for example, go up instead of down) when the ball hit with the middle of the bat.
The computer may wait a ball at the wrong place (off by 1), especially if the ball would bounce.
When you use Sleep the whole program stop for some milliseconds.
Do you have a game loop ? If so, try decreasing the translation amount, and do not forget to normalize
the acceleration vector.
cpuPadlle.Position += amount * acceleration;
Where :
amount in [0..1]
acceleration is a 2d
vector

Resources