Discuss Scratch

game_pr0grammer
Scratcher
500+ posts

moving enemies in a scrolling platformer

project

I'm making a scrolling platformer, and I wanted to make some enemies other than the color yellow. In the project, I made an enemy that, when it enters the screen, turns towards the player, and until it leaves the screen, runs forward.

The enemy turns around when it hits a wall and is affected by gravity; however, when I tested the enemy, it would get stuck on the ground and frantically turn around. I understand why this happens–the enemy doesn't seem to move upwards when it touches the ground so it gets stuck, and since the enemy thinks it's touching a wall, it keeps turning around. What I don't understand is why the enemy gets stuck on the ground. Please help!
VintageAura
Scratcher
100+ posts

moving enemies in a scrolling platformer

most likely because whenever I check,
<(x position) < [0]>
returns false on a fireboy with -76 x
So it's obviously true, so the boolean is contradicting itself. I think this might actually cause lag too. try
<([abs v] of (x position)) = (x position)>

Last edited by VintageAura (Dec. 16, 2018 00:31:06)

game_pr0grammer
Scratcher
500+ posts

moving enemies in a scrolling platformer

VintageAura wrote:

most likely because whenever I check, ~~~
returns false on a fireboy with -76 x
So it's obviously true, so the boolean is contradicting itself. I think this might actually cause lag too. try
~~~

okay but it doesn't fix the bug
deck26
Scratcher
1000+ posts

moving enemies in a scrolling platformer

The problem looks to be the turn 180 degrees block - why are you doing that?

I hate that script which repeats ‘if touching colour, change y by 1’. Check out @griffpatch_tutor's platformer tutorial for better platformer scripts.
game_pr0grammer
Scratcher
500+ posts

moving enemies in a scrolling platformer

deck26 wrote:

The problem looks to be the turn 180 degrees block - why are you doing that?

to turn the enemy around when it touches a wall
deck26
Scratcher
1000+ posts

moving enemies in a scrolling platformer

So if the hitbox is touching the floor it will change direction every time through the loop.
game_pr0grammer
Scratcher
500+ posts

moving enemies in a scrolling platformer

when i remove the block, it still falls through the ground
deck26
Scratcher
1000+ posts

moving enemies in a scrolling platformer

I was addressing the issue of the enemy switching direction repeatedly - I've not seen it fall through the ground but as long as you're using that script I referred to I'm afraid I'm not going to get involved. That script regularly appears here as a problem and I'm not wasting time on it.
deck26
Scratcher
1000+ posts

moving enemies in a scrolling platformer

However you may want to check the centre of the hitbox costume.
meap12134
Scratcher
1 post

moving enemies in a scrolling platformer

m
game_pr0grammer
Scratcher
500+ posts

moving enemies in a scrolling platformer

meap12134 wrote:

m

Thank you for your tip. It was very helpful.

p.s. that was sarcasm

Last edited by game_pr0grammer (Dec. 4, 2019 00:10:08)

Wainggan
Scratcher
500+ posts

moving enemies in a scrolling platformer

meap12134 wrote:

m
This is necroposting, and it is bad.
MTM828
Scratcher
500+ posts

moving enemies in a scrolling platformer

You unshared it so I can't help, but what's wrong with this? It just has so many problems which I don't know where they come from, like the hitbox and sudden lag plus somehow (I don't know why) HE SINKS THROUGH THE GROUND. And just to help understand the code, I just added scrolling to Griffpatch's platformer (the one in his tutorial).
joshuaho
Scratcher
1000+ posts

moving enemies in a scrolling platformer

Hey folks - this thread is rather old. Please feel free to make a new topic if you have a new question regarding to project scripting. Doing so will make it easier for others to find your question.

It would also be a good idea to share your project and provide a link to it, so others will be able to see what exactly needs to be fixed.

Powered by DjangoBB