kidscancode / godot3_dodge Goto Github PK
View Code? Open in Web Editor NEW"Dodge the Creeps!" Godot Engine 3.0 "getting started" game demonstrating the basics.
License: MIT License
"Dodge the Creeps!" Godot Engine 3.0 "getting started" game demonstrating the basics.
License: MIT License
If the player suffers an early death then StartTimer can fire after the game over.
This kicks off MobTimer and ScoreTimer which continue to fire while the menu is displayed.
This can exacerbate the problem because MobTimer will ensure that there are enemies on the screen increasing the likely-hood of an early death next time.
The line $Collision.disabled = false
at
https://github.com/kidscancode/Godot3_dodge/blob/master/Player.gd#L16 this line is not mentioned in the guide (https://godot.readthedocs.io/en/latest/learning/step_by_step/your_first_game.html)
The line $Collision.disabled = true
at
https://github.com/kidscancode/Godot3_dodge/blob/master/Player.gd#L47 is not mentioned, instead call_deferred("set_monitoring", false)
is suggested with a rationale "you can defer the change, which will tell the game engine to wait until itβs safe to set monitoring to false", is this true?
The screenshot https://godot.readthedocs.io/en/latest/_images/player_scene_nodes.png has a node named "Collision". The guide doesn't mention naming it like this.
I did everything equal to your programm. yours working, my isnt working. The last thing what i need to implement is the music all other i finisched but my Enemies didnt spawn i cant find the issue.
Hope u can look over it.
Main:
extends Node
export (PackedScene) var Mob
var scorefunc _ready():
randomize()func game_over():
$ScoreTimer.stop()
$MobTimer.stop()
$HUD.show_game_over()
#get_tree().call_group("mobs", "queue_free")func new_game():
score = 0
$Player.start($StartPosition.position)
$StartTimer.start()
$HUD.update_score(score)
$HUD.show_message("Get Ready")func _on_MobTimer_timeout():
$MobPath/MobSpawnLocation.offset = randi()
var mob = Mob.instance()
add_child(mob)
var direction = $MobPath/MobSpawnLocation.rotation + PI / 2
mob.position = $MobPath/MobSpawnLocation.position
direction += rand_range(-PI / 4, PI / 4)
mob.rotation = direction
mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
mob.linear_velocity = mob.linear_velocity.rotated(direction)func _on_StartTimer_timeout():
$MobTimer.start()
$ScoreTimer.start()func _on_ScoreTimer_timeout():
score += 1
$HUD.update_score(score)
Player:
extends Area2D
signal hit
export var speed = 400
var screen_size #size of the game windowfunc _ready():
screen_size = get_viewport_rect().size
hide()func _process(delta):
var velocity = Vector2() #The players movment
if Input.is_action_pressed("ui_right"):
velocity.x += 1
if Input.is_action_pressed("ui_left"):
velocity.x -= 1
if Input.is_action_pressed("ui_down"):
velocity.y += 1
if Input.is_action_pressed("ui_up"):
velocity.y -= 1
if velocity.length() >0:
velocity = velocity.normalized() * speed
$AnimatedSprite.play()
else:
$AnimatedSprite.stop()position += velocity * delta
position.x = clamp(position.x, 0, screen_size.x)
position.y = clamp(position.y, 0, screen_size.y)if velocity.x != 0:
$AnimatedSprite.animation = "Walk"
$AnimatedSprite.flip_v = false
# See the note below about boolean assignment
$AnimatedSprite.flip_h = velocity.x < 0
elif velocity.y != 0:
$AnimatedSprite.animation = "up"
$AnimatedSprite.flip_v = velocity.y > 0func _on_Player_body_entered(body):
hide()
emit_signal("hit")
$CollisionShape2D.set_deferred("disabled", true)func start(pos):
position = pos
show()
$CollisionShape2D.disabled = false
Mob:
extends RigidBody2D
export var min_speed = 150 # Minimum speed range.
export var max_speed = 250 # Maximum speed range.func _ready():
var mob_types = $AnimatedSprite.frames.get_animation_names()
$AnimatedSprite.animation = mob_types[randi() % mob_types.size()]func _on_VisibilityNotifier2D_screen_exited():
queue_free()
HUD:
extends CanvasLayer
signal start_game
func show_message(text):
$Message.text = text
$Message.show()
$MessageTimer.start()func show_game_over():
show_message("Game Over")
# Wait until the MessageTimer has counted down.
yield($MessageTimer, "timeout")
$Message.text = "Dodge the\nCreeps!"
$Message.show()
yield(get_tree().create_timer(1), "timeout")
$StartButton.show()func update_score(score):
$ScoreLabel.text = str(score)func _on_StartButton_pressed():
$StartButton.hide()
emit_signal("start_game")func _on_MessageTimer_timeout():
$Message.hide()
Following the tutorial, I added the Particle2D node at the end, but when I imported the playerGrey_up1.png resource as the 'texture' (as shown in the tutorial instructions) I got a particle trail that was twice as big as the Player icon. I know the Player icon had to be scaled to 0.5, 0.5 size, but there was apparently no way to downscale the particle trail to fit the Player icon. Thus, when moving the Player icon in the game, it would leave a trail of fading supersize (2X size) Player icons - very weird.
This is the error I get when I press the "Start" button after running the game. I don't know where I went wrong or how. I used the video on youtube, as well as the Godot Docs step-by-step.
I'm getting this error:
Invalid call. Nonexistent function 'set_deferred' in base 'CollisionShape2D' when the player is hit.
Hi there. Just went through this tutorial, and it was mostly smooth sailing, but one detail let me scratching my head for a while. I think it should be clarified that when creating the game_over signal, you need to be in the Main scene in order to connect from the player node to the main node. If you're in the Player scene, the main node isn't available. It makes sense in retrospect, but if someone is just following the steps this is a very easy mistake to make, especially since the tutorial doesn't explicitly say you're connecting to Main and not Player. I only figured it out when downloading this source and looking at Main.tscn in text. That's all, thanks!
In Mob.gd the function
func _process(delta):
$AnimatedSprite.play()
is missing. As the guide stands the mobs have an animation but it's simply not played.
Thank you for the introductory guide :)
Hello everyone,
When i try to add "particles2d" node and make the settings like the documentation. Player turns to black.
Actually, i couldn't find how can i change the "Visibility Rect" setting to "Rect3"
As the title says I can't get the Deathsound to play. Music plays without issue but whenever 'game over' occurs I get the error: Node not found: DeathSound.
The .wav file is loaded in the streaming box. I listened to and it plays fine in windows. Without the deathsound file the game plays fine.
Anyone else have this issue?
extends Area2D
export (int) var speed #how fast the player will move
func _ready():
screensize = get_viewport_rect().size
func _process(delta):
var velocity = vector2() #player's movement vector
if Input.action_pressed("ui_right"):
velocity.x += 1
if Input.actio_pressed("ui_left"):
velocity.x -= 1
if Input.is_action_pressed("ui_down"):
velocity.y += 1
if Input.is_action_pressed("ui_up"):
velocity.y -= 1
if velocity.length() > 0:
velocity = velocity.normalized() * speed
$AnimatedSprite.play()
else:
$AnimatedSprite.stop()
position += velocity * delta
position.x = clamp(position.x, 0, screensize.x)
position.y = clamp(position.y, 0, screensize.y)
This is the code from the tutorial. When I tried to run it. It throws error:
Parser Error: Identifiers not found: screensize
Please help
Hey!
So, just one thing, when you talk about MessageLabel you should say that Align
and Valign
needs to be centered, otherwise someone can get a headache π
Can this game be scripted using visual scripting instead of gdscript?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.