Mudanças entre as edições de "Godot Engine: SkyFire"

De Aulas
Linha 39: Linha 39:
 
== Background ==
 
== Background ==
  
<syntaxhighlight lang=python>
+
<syntaxhighlight lang=gdscript>
 
extends Node2D
 
extends Node2D
  

Edição das 16h16min de 18 de novembro de 2022

Afluentes : Jogos Digitais, Usabilidade, desenvolvimento web, mobile e jogos

Assets

Estrutura

  • BackGround (Node2D)
    • A (Sprite)
    • B (Sprite)
  • Ship (KinematicBody2D)
    • Sprite
    • CollisionShape2D
  • Enemy (KinematicBody2D)
    • Sprite
    • CollisionShape2D
  • Bomb (KinematicBody2D)
    • Sprite
    • CollisionShape2D
    • SoundBomb (AudioStreamPlayer)
  • Explosion (StaticBody2D)
    • AnimatedSprite
    • CollisionShape2D
    • SoundExplosion (AudioStreamPlayer)
    • Nó (sinal) - _on_AnimatedSprite_finished()
  • World (Node2D)
    • Background (instancia)
    • Ship (instancia)
    • EnemiTimer (Timer)
    • Music (AudioStreamPlayer)
    • GameOver (TextureRect)
    • Label (Label)
    • Score (Label)

Scripts

Background

extends Node2D

var speed = 100
var h
var half_h
var screensize

func _ready():
	screensize = get_viewport_rect().size
	h = $A.texture.get_height()
	half_h = h / 2


func _process(delta):
	$A.position.y += speed * delta
	$B.position.y += speed * delta
	if $A.position.y - half_h > screensize.y:
		$A.position.y -= h * 2
	if $B.position.y - half_h > screensize.y:
		$B.position.y -= h * 2