helppp
guys how do I make my character move and interact with a background I drew myself personally? this applies in any coding app for games (for 2D games tho)
About this post
- Posted
- Archived
- Score
- 0 · 18% up
- Kind
- Text
- ID
- 1imgpr5
guys how do I make my character move and interact with a background I drew myself personally? this applies in any coding app for games (for 2D games tho)
3 comments
Nothing applies to "any coding app for games", it fully depends on what game engine and/or language you're using to make your game.
So a couple of pointers when asking for help for a development community you need to:
Now for your question at hand, assuming your background is one asset and character another. You would need to:
It’s going to depend on what engine/language you’re using, but it’ll generally look something like the following.
For movement:
Every game update, check for what movement inputs/buttons are being pressed. Then update the player characters position by a certain increment in the direction that the inputs are moving the character in. Once you’ve added collision detection, you’ll also want to make sure to check for collisions before you move the character to stop the player from being able to walk through objects.
For interacting with parts of the background:
Decide which parts of the background are interactable and what they will do.
Design a way to detect when the player is interacting/can interact with those different parts of that background. This will usually involve implementing colliders or at least some logic to check the position of the player relative to the interactable element. If interacting involves a key press or other input you’ll also need a way to detect that.
Write logic that handles what happens when the player interacts with that interactable element.