+1 vote

Hey!

The game I'm trying to make involves the player having to control a rocket ship as it blasts off into space avoiding various projectiles.

I'd like to have it where the rocket rests at the bottom of the screen and you can only move it either left or right in order to avoid obstacles which will move down towards the player.

Right now I'm trying to create a beta version that has:
- A player sprite that can be moved left and right
- Randomly generated enemies that are either static or move from one side of the screen to the other
- The ability to die when coming into contact with an enemy

If you have any suggestions on how to approach any or all of these features I'd sincerely appreciate it. I also realize that this is kind of a vague overview so if you'd like me to get more specific on certain parts feel free to ask!

Thanks for your time!

asked May 29 in Engine by BadWisp (13 points)

1 Answer

0 votes

Hi BadWisp,
Im new on godot but i will help you as much as I can:

Q:A player sprite that can be moved left and right
A: using Input, just like this:

First Define The Move and speed it self
var motion = Vector2.ZERO
var speed = 20

and then use if else statement for most basic ways

if Input.is_action_pressed('ui_left'):
motion.x -= speed
elif Input.is_action_pressed('ui_right):
motion.x += speed

if you want to make it more clean, you can use
motion.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")

what is ui_left and ui_right? check your Project->Project Setting->Input Map

and then start move
move_and_slide(motion)

for more, you can read doc about it

Q: Randomly generated enemies that are either static or move from one side of the screen to the other
A: Implement Move above and give Random place to move and respawn using rand(), you can learn rand from many documentation

Q:The ability to die when coming into contact with an enemy
A: First Create new Scene that had your kinematic2d and then add hurt box using Area2d on Enemy that you create before In Area2d inside Node tab, you can see area_entered(area: Area2d) you can use that to your player, and be careful, always use Layer and Mask so the enemy know which one enemy and player

I'm sorry for my bad English, hope it help, you can ask me more on my email:
gakonok@gmail.com, have a good day!

answered May 29 by mohammad nanda (21 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.