Skip to content

Commit

Permalink
commit inicial, al tilemap se le pueden añadir y quitar sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioJimenezM committed Sep 22, 2019
1 parent 4d42038 commit 04918da
Show file tree
Hide file tree
Showing 12 changed files with 246 additions and 0 deletions.
7 changes: 7 additions & 0 deletions default_env.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]

[sub_resource type="ProceduralSky" id=1]

[resource]
background_mode = 2
background_sky = SubResource( 1 )
Binary file added icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions icon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
12 changes: 12 additions & 0 deletions mapaProvicional.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://scripts/editorScript.gd" type="Script" id=1]
[ext_resource path="res://tileSet/tileset.tres" type="TileSet" id=2]

[node name="Node2D" type="Node2D"]
script = ExtResource( 1 )

[node name="TileMap" type="TileMap" parent="."]
tile_set = ExtResource( 2 )
format = 1
tile_data = PoolIntArray( 65539, 0, 0, 131078, 1, 0, 196612, 0, 0 )
24 changes: 24 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=4

_global_script_classes=[ ]
_global_script_class_icons={

}

[application]

config/name="EditorDeMapas"
run/main_scene="res://mapaProvicional.tscn"
config/icon="res://icon.png"

[rendering]

environment/default_environment="res://default_env.tres"
31 changes: 31 additions & 0 deletions scripts/editorScript.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
extends Node2D

#primero funcion los botones izquierdo y derecho
#la escena debe tener mas controles, cambiando los tiles a colocar
#codigo de prototipo finalizado 21/sep/19
# :3
#de anubarak para quien lo necesite
#licencia MIT :D

var tileMap
func _ready():
tileMap = $TileMap
#se toma el nodo hijo para mayor comodidad

func _input(event):
if(event is InputEventMouseButton):
#toma las presiones del mouse
if(event.button_index == BUTTON_LEFT and event.pressed):
#en caso de presionar el boton izquierdo
var tilePos = tileMap.world_to_map(event.position)
#toma un vector(x,y) y lo traduce en coordenadas de malla
tileMap.set_cellv(tilePos, 0)
#cambia la celda de la posicion por el sprite 0

if(event.button_index == BUTTON_RIGHT and event.pressed):
#igual pero con el boton contrario
var tilePos = tileMap.world_to_map(event.position)
#exactamente lo mismo, pero la posicion cambiará
tileMap.set_cellv(tilePos, -1)
#un -1 va a eliminar el sprite en ese sitio de la malla

Binary file added sprites/hierba.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions sprites/hierba.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/hierba.png-5818438993c6964ef9066feef6a28700.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://sprites/hierba.png"
dest_files=[ "res://.import/hierba.png-5818438993c6964ef9066feef6a28700.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Binary file added sprites/tierra.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions sprites/tierra.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/tierra.png-b6af56920143da16a10e0b18c4251412.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://sprites/tierra.png"
dest_files=[ "res://.import/tierra.png-b6af56920143da16a10e0b18c4251412.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
27 changes: 27 additions & 0 deletions tileScene/tileset.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://sprites/hierba.png" type="Texture" id=1]
[ext_resource path="res://sprites/tierra.png" type="Texture" id=2]

[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 31.9665, 31.9681 )

[node name="Node2D" type="Node2D"]

[node name="hierba" type="Sprite" parent="."]
position = Vector2( 40, 40 )
texture = ExtResource( 1 )

[node name="StaticBody2D" type="StaticBody2D" parent="hierba"]

[node name="CollisionShape2D" type="CollisionShape2D" parent="hierba/StaticBody2D"]
shape = SubResource( 1 )

[node name="tierra" type="Sprite" parent="."]
position = Vector2( 110, 40 )
texture = ExtResource( 2 )

[node name="StaticBody2D2" type="StaticBody2D" parent="tierra"]

[node name="CollisionShape2D" type="CollisionShape2D" parent="tierra/StaticBody2D2"]
shape = SubResource( 1 )
43 changes: 43 additions & 0 deletions tileSet/tileset.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[gd_resource type="TileSet" load_steps=4 format=2]

[ext_resource path="res://sprites/hierba.png" type="Texture" id=1]
[ext_resource path="res://sprites/tierra.png" type="Texture" id=2]



[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 31.9665, 31.9681 )

[resource]
0/name = "hierba"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 0, 0, 64, 64 )
0/tile_mode = 0
0/occluder_offset = Vector2( 32, 32 )
0/navigation_offset = Vector2( 32, 32 )
0/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 1 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 32, 32 )
} ]
0/z_index = 0
1/name = "tierra"
1/texture = ExtResource( 2 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 1, 1, 1 )
1/region = Rect2( 0, 0, 64, 64 )
1/tile_mode = 0
1/occluder_offset = Vector2( 32, 32 )
1/navigation_offset = Vector2( 32, 32 )
1/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 1 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 32, 32 )
} ]
1/z_index = 0

0 comments on commit 04918da

Please sign in to comment.