Discuss Scratch

InfernoCyclops123
Scratcher
66 posts

[SOLVED] Centered player camera system movement thingy

Honestly i could probably do this if i use more than 2% of my brain but here I am asking you guys for help

How to create a movement system where the camera follows the sprite? (the sprite stays centered) and specificly how to make seperate enemies render in and make player stop when hitting a wall? (I'm assuming pressing arrows changes x & y variables but idk after that)

(I dont really need specific instructions, I just want to understand the structure of the code/how it works)

Last edited by InfernoCyclops123 (Feb. 1, 2024 03:19:46)

PhiPhenomenon
Scratcher
500+ posts

[SOLVED] Centered player camera system movement thingy

Is this a 2D game? When you say “render in” it makes me think you're doing a 3D raycaster.
InfernoCyclops123
Scratcher
66 posts

[SOLVED] Centered player camera system movement thingy

Nvm, I almost forgot “change rotation style” exists (im so serious T_T)
InfernoCyclops123
Scratcher
66 posts

[SOLVED] Centered player camera system movement thingy

PhiPhenomenon wrote:

Is this a 2D game? When you say “render in” it makes me think you're doing a 3D raycaster.
nah I meant like a moba game, it is 2d and when i say render i just mean the sprite shows when in the player's viewing distance
Malicondi
Scratcher
1000+ posts

[SOLVED] Centered player camera system movement thingy

InfernoCyclops123 wrote:

Honestly i could probably do this if i use more than 2% of my brain but here I am asking you guys for help

How to create a movement system where the camera follows the sprite? (the sprite stays centered) and specificly how to make seperate enemies render in and make player stop when hitting a wall? (I'm assuming pressing arrows changes x & y variables but idk after that)

(I dont really need specific instructions, I just want to understand the structure of the code/how it works)
i wanna explain it, but its r eally long and (kinda) complicated
InfernoCyclops123
Scratcher
66 posts

[SOLVED] Centered player camera system movement thingy

Malicondi wrote:

InfernoCyclops123 wrote:

Honestly i could probably do this if i use more than 2% of my brain but here I am asking you guys for help

How to create a movement system where the camera follows the sprite? (the sprite stays centered) and specificly how to make seperate enemies render in and make player stop when hitting a wall? (I'm assuming pressing arrows changes x & y variables but idk after that)

(I dont really need specific instructions, I just want to understand the structure of the code/how it works)
i wanna explain it, but its r eally long and (kinda) complicated

dw I figured it out. I forgot that rotation styles exist so i got kinda stuck XD
PhiPhenomenon
Scratcher
500+ posts

[SOLVED] Centered player camera system movement thingy

InfernoCyclops123 wrote:

How to create a movement system where the camera follows the sprite?
The most frequent way of doing this is having an x and y pair for the player and the enemy. Because the player will be at the center of the screen at all times, the enemies will position themselves relative to the player. So you subtract the player's coordinates from the enemy's.



InfernoCyclops123 wrote:

specificly how to make seperate enemies render in
This one's pretty simple. You just have to check if the enemy is within a certain bound. So you would position it first and then check if the relative x and y are within the stage.

InfernoCyclops123 wrote:

make player stop when hitting a wall
My way of doing this is: when the player moves into the wall, move the player back out of it the same amount. So if the player moves to the right 5 steps and it detects it is touching a wall, move it 5 steps to the left. This is all in one frame, so it won't show that it even touched the wall at all.

Powered by DjangoBB