This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

So i am new to Godot but i am trying to learng how to make a my first game. I am having issues with the dodge the creeps game. when running the game I dont see any enemies but the timer is counting and i am walking around. a few seconds in, the player disappears but the timer continues (leading me to believe the enemies are invisible but there is no game over message).

One thing to mention before looking at the code, all mobs have been changed to zombies. so whenerv you see zomies that means mob n the case of the dodge the creeps game. if you could explain it to me in zombie, it would be better so I dont get confused.

I code for everything so far is below:

extends CanvasLayer

signal start_game

func show_message(text):
$MessageLabel.text = text

func gameover():
message("Game Over")
yield($MessageTimer, "timeout")
$MessageLabel.text = "Don't Touch \nMe"

func update_score(score):
$ScoreLabel.text = str(score)

func onMessageTimer_timeout():

func onStartButtonpressed():

extends Area2D

signal hit

export(int) var SPEED
var velocity = Vector2()
var screensize

func ready():
screensize = get

func process(delta):
velocity = Vector2()
velocity = velocity.normalized() * SPEED
velocity.x += 1
if Input.isactionpressed("uileft"):
velocity.x -= 1
velocity.y += 1
if Input.isactionpressed("ui_up"):
velocity.y -= 1
if velocity.length() > 0:
velocity = velocity.normalized() * SPEED
$AnimatedSprite.animation = "Left"
position += velocity * delta
position.x = clamp(position.x, 0, screensize.x)
position.y = clamp(position.y, 0, screensize.y)

if velocity.x != 0 || velocity.y != 0:
    $AnimatedSprite.animation = "Right"
    $AnimatedSprite.flip_v = false
    $AnimatedSprite.flip_h = velocity.x < 0
#for up of down flipping
#elif velocity.y != 0:
    #$AnimatedSprite.animation = "Left"
    #$AnimatedSprite.flip_v = velocity.y < 0
    #$AnimatedSprite.flip_h = false

func onplayerbodyentered(body):
$CollisionShape2D.disabled = true

func start(pos):
position = pos
$CollisionShape2D.disabled = false

extends Node

export (PackedScene) var Zombie
var score

func _ready():

func newgame():
score = 0
$HUD.show_message("Get Ready")

func gameover():

func onStartTimer_timeout():

func onScoreTimertimeout():
score += 1

func onZombieTimertimeout():
var zombie = Zombie.instance() #create a zombie and add to the scene
var direction = $ZombiePath/ZombieSpawnLocation.rotation
zombie.position = $ZombiePath/ZombieSpawnLocation.position
direction += rand
range(-PI/4, PI/4) #to not only move up, down, left, right (add randomness)
zombie.rotation = direction
zombie.setlinearvelocity(Vector2(randrange(zombie.MINSPEED, zombie.MAX_SPEED), 0).rotated(direction))

extends RigidBody2D

export(int) var MINSPEED #min speed of enemy
export(int) var MAX
SPEED #max speed of enemy
var mob_types = ["Zombie", "ZombieStrong", "ZombieFat"]

func ready():
$AnimatedSprite.animation = mob
types[randi() % mob_types.size()]

func onVisibilityNotifier2Dscreenexited():

in Engine by (12 points)
edited by

1 Answer

0 votes

I had this problem as well. I solved it by checking the animation names in my AnimatedSprite node. There was a mismatch between the names I gave the animation cycles and the ones i listed under var mob_types in my mob script.

by (14 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.