Skip to content

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)

0 points3 comments
Open on Reddit
About this post
Posted
Archived
Score
0 · 18% up
Kind
Text
ID
1imgpr5

Author

3
posts
0
comments
0
media
View profile

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.

2 points

So a couple of pointers when asking for help for a development community you need to:

  • be concise, what is the problem, what have you tried, what is the solution you are aiming for
  • provide as much detail as possible e.g game engine in use, programming language you are using
  • include the code by using reddits markdown capabilities so people can assist you

Now for your question at hand, assuming your background is one asset and character another. You would need to:

  • get user input vector
  • multiply input vector by movespeed
  • smooth the final vector by multiplying by frame delta
  • apply the movement using the final smoothed vector
2 points

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:

  1. Decide which parts of the background are interactable and what they will do.

  2. 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.

  3. Write logic that handles what happens when the player interacts with that interactable element.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.