Switch to 3D

This commit is contained in:
Hamcha 2019-05-04 21:33:47 +02:00
parent 3027e4f080
commit 1358cd5886
Signed by: hamcha
GPG key ID: A40413D21021EAEE
17 changed files with 333 additions and 43 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

View file

@ -0,0 +1,36 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/boardbg.jpg-892d674dbade1effb8d6d07916c18ae8.s3tc.stex"
path.etc="res://.import/boardbg.jpg-892d674dbade1effb8d6d07916c18ae8.etc.stex"
metadata={
"imported_formats": [ "s3tc", "etc" ],
"vram_texture": true
}
[deps]
source_file="res://MLPAssets/Background/boardbg.jpg"
dest_files=[ "res://.import/boardbg.jpg-892d674dbade1effb8d6d07916c18ae8.s3tc.stex", "res://.import/boardbg.jpg-892d674dbade1effb8d6d07916c18ae8.etc.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.8
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
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=false
svg/scale=1.0

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,11 @@
# Exported from Wings 3D 2.2.1
newmtl Cube2_auv
Ns 19.999999999999996
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 0.0 0.0 0.0
Ks 0.19 0.19 0.19
Ke 0.0 0.0 0.0
map_Kd CardBack.png

View file

@ -0,0 +1,99 @@
# Exported from Wings 3D 2.2.1
mtllib cardborder.mtl
o Cube2
#16 vertices, 28 faces
v -1.72000000 3.2818681e-2 -2.18667858
v -1.67165352 3.2818681e-2 -2.30339731
v -1.62339731 3.2818681e-2 -2.35165352
v -1.50667858 3.2818681e-2 -2.40000000
v -1.72000000 3.2818681e-2 2.18667858
v -1.67165352 3.2818681e-2 2.30339731
v -1.50667858 3.2818681e-2 2.40000000
v -1.62339731 3.2818681e-2 2.35165352
v 1.50667858 3.2818681e-2 -2.40000000
v 1.62339731 3.2818681e-2 -2.35165352
v 1.67165352 3.2818681e-2 -2.30339731
v 1.72000000 3.2818681e-2 -2.18667858
v 1.72000000 3.2818681e-2 2.18667858
v 1.67165352 3.2818681e-2 2.30339731
v 1.62339731 3.2818681e-2 2.35165352
v 1.50667858 3.2818681e-2 2.40000000
vt 4.1666667e-2 4.4441963e-2
vt 4.1666667e-2 0.95555804
vt 5.1738851e-2 2.0125561e-2
vt 5.1738851e-2 0.97987444
vt 6.1792227e-2 1.0072184e-2
vt 6.1792227e-2 0.98992782
vt 8.6108630e-2 1.6151895e-14
vt 8.6108630e-2 1.00000000
vt 0.71389137 0.0000000e+0
vt 0.71389137 1.00000000
vt 0.73820777 1.0072184e-2
vt 0.73820777 0.98992782
vt 0.74826115 2.0125561e-2
vt 0.74826115 0.97987444
vt 0.75833333 4.4441963e-2
vt 0.75833333 0.95555804
vt 0.78431656 0.34479267
vt 0.78431656 0.58110397
vt 0.78692892 0.33848585
vt 0.78692892 0.58741079
vt 0.78953641 0.33587836
vt 0.78953641 0.59001828
vt 0.79584323 0.33326599
vt 0.79584323 0.59263065
vt 0.95866788 0.33326599
vt 0.95866788 0.59263065
vt 0.96497470 0.33587836
vt 0.96497470 0.59001828
vt 0.96758219 0.33848585
vt 0.96758219 0.58741079
vt 0.97019456 0.34479267
vt 0.97019456 0.58110397
vn 0.0000000e+0 1.00000000 5.9098621e-18
vn 0.0000000e+0 -1.00000000 -5.9468352e-17
vn 0.0000000e+0 1.00000000 5.9468352e-17
vn 0.0000000e+0 -1.00000000 -1.8694771e-28
vn 0.0000000e+0 -1.00000000 -9.3473854e-29
vn 0.0000000e+0 1.00000000 -5.9468352e-17
vn 0.0000000e+0 1.00000000 -1.8694771e-28
vn 0.0000000e+0 -1.00000000 5.9468352e-17
vn 0.0000000e+0 1.00000000 1.1819724e-17
vn 0.0000000e+0 -1.00000000 -5.9468352e-17
vn 0.0000000e+0 1.00000000 5.9468352e-17
vn 0.0000000e+0 -1.00000000 5.9098621e-18
vn 0.0000000e+0 1.00000000 9.3473854e-29
vn 0.0000000e+0 -1.00000000 5.9468352e-17
vn 0.0000000e+0 1.00000000 -5.9468352e-17
vn 0.0000000e+0 -1.00000000 1.8694771e-28
g Cube2_Cube2_auv
usemtl Cube2_auv
s 1
f 1/16/1 12/2/12 5/15/5
f 2/20/2 1/18/1 3/22/3
f 2/14/2 4/10/4 1/16/1
f 3/22/3 1/18/1 4/24/4
f 3/12/3 4/10/4 2/14/2
f 4/24/4 1/18/1 9/26/9
f 5/17/5 13/31/13 1/18/1
f 6/13/6 5/15/5 8/11/8
f 6/19/6 7/23/7 5/17/5
f 7/9/7 5/15/5 16/7/16
f 8/11/8 5/15/5 7/9/7
f 8/21/8 7/23/7 6/19/6
f 9/8/9 1/16/1 4/10/4
f 9/26/9 1/18/1 12/32/12
f 9/8/9 12/2/12 1/16/1
f 10/28/10 9/26/9 11/30/11
f 10/6/10 12/2/12 9/8/9
f 11/30/11 9/26/9 12/32/12
f 11/4/11 12/2/12 10/6/10
f 12/32/12 1/18/1 13/31/13
f 13/1/13 5/15/5 12/2/12
f 13/1/13 16/7/16 5/15/5
f 14/29/14 13/31/13 15/27/15
f 14/3/14 16/7/16 13/1/13
f 15/27/15 13/31/13 16/25/16
f 15/5/15 16/7/16 14/3/14
f 16/25/16 5/17/5 7/23/7
f 16/25/16 13/31/13 5/17/5

View file

@ -0,0 +1,18 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/cardborder.obj-a6a8929c16d8d520e99a408fe4e7f808.mesh"
[deps]
files=[ "res://.import/cardborder.obj-a6a8929c16d8d520e99a408fe4e7f808.mesh" ]
source_file="res://MLPAssets/Models/cardborder.obj"
dest_files=[ "res://.import/cardborder.obj-a6a8929c16d8d520e99a408fe4e7f808.mesh", "res://.import/cardborder.obj-a6a8929c16d8d520e99a408fe4e7f808.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 0.2, 0.2, 0.2 )
optimize_mesh=true

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://MLPAssets/Textures/CardBack.png"
dest_files=[ "res://.import/CardBack.png-c3e28c09100eabc5562ed76709826ce0.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
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=false
svg/scale=1.0

29
Scenes/Board.tscn Normal file
View file

@ -0,0 +1,29 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Scenes/Scripts/Board.gd" type="Script" id=1]
[ext_resource path="res://Scenes/Scripts/Camera.gd" type="Script" id=2]
[ext_resource path="res://MLPAssets/Background/boardbg.jpg" type="Texture" id=3]
[ext_resource path="res://Scenes/Components/Card.tscn" type="PackedScene" id=4]
[sub_resource type="SpatialMaterial" id=2]
flags_unshaded = true
albedo_texture = ExtResource( 3 )
[sub_resource type="PlaneMesh" id=3]
material = SubResource( 2 )
size = Vector2( 16, 9 )
[node name="Spatial" type="Spatial"]
script = ExtResource( 1 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.367808, 0.929902, 0, -0.929902, 0.367808, -0.232958, 4.94606, 3.11883 )
script = ExtResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.001, 0 )
mesh = SubResource( 3 )
material/0 = null
[node name="Card" parent="." instance=ExtResource( 4 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.433312, -0.001, 1.49195 )

View file

@ -1,17 +1,58 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=5 format=2]
[sub_resource type="ImageTexture" id=1]
[ext_resource path="res://MLPAssets/Models/cardborder.obj" type="ArrayMesh" id=1]
[ext_resource path="res://MLPAssets/Models/cardborder.material" type="Material" id=2]
[node name="Node2D" type="Node2D"]
[sub_resource type="Animation" id=2]
resource_name = "flip"
length = 0.5
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath(".:translation")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0.00886994, 0.25, 0.5 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0.5, 0 ), Vector3( 0, 0, 0 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath(".:rotation_degrees")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0.00886994, 0.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0, 180 ) ]
}
[node name="Border" type="Polygon2D" parent="."]
color = Color( 0, 0, 0, 1 )
offset = Vector2( -180, -240 )
antialiased = true
polygon = PoolVector2Array( 4, 4, 9, 1, 16, 0, 324, 0, 331, 1, 336, 4, 339, 9, 340, 16, 340, 464, 339, 471, 336, 476, 331, 479, 324, 480, 16, 480, 9, 479, 4, 476, 1, 471, 0, 464, 0, 16, 1, 9 )
[sub_resource type="Animation" id=1]
resource_name = "tap"
length = 0.3
tracks/0/type = "value"
tracks/0/path = NodePath(".:rotation_degrees")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.3 ),
"transitions": PoolRealArray( 0.466516, 2.37841 ),
"update": 0,
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, -90, 0 ) ]
}
[node name="InsideBG" type="Polygon2D" parent="Border"]
offset = Vector2( -180, -240 )
antialiased = true
texture = SubResource( 1 )
polygon = PoolVector2Array( 18, 18, 322, 18, 322, 462, 18, 462 )
[node name="Card" type="MeshInstance"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
mesh = ExtResource( 1 )
material/0 = ExtResource( 2 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/flip = SubResource( 2 )
anims/tap = SubResource( 1 )

View file

@ -1,15 +0,0 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Scenes/Scripts/Game.gd" type="Script" id=1]
[ext_resource path="res://Scenes/Components/Card.tscn" type="PackedScene" id=2]
[node name="Node2D" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
[node name="Board" type="Node2D" parent="."]
[node name="Node2D3" parent="Board" instance=ExtResource( 2 )]
position = Vector2( 736.851, 566.497 )
scale = Vector2( 0.3, 0.3 )

24
Scenes/Scripts/Board.gd Normal file
View file

@ -0,0 +1,24 @@
extends Spatial
onready var camera := $Camera
var mouseOrigin: Vector2
var lastCameraTransform: Transform
func _input(event: InputEvent):
# Camera zoom
if event.is_action("zoom_in"):
camera.zoom(true)
elif event.is_action("zoom_out"):
camera.zoom(false)
# Save original camera and mouse position before panning
if event.is_action_pressed("pan"):
mouseOrigin = get_viewport().get_mouse_position()
lastCameraTransform = camera.transform
func _process(delta):
# If panning, translate mouse delta to camera delta
if Input.is_action_pressed("pan"):
var mouseDelta := get_viewport().get_mouse_position() - mouseOrigin
var mousePos: Vector2 = mouseDelta * 0.0096 * (1-camera.getZoomLevel()/5) # Magic numbers everywhere
camera.transform.origin = lastCameraTransform.origin - Vector3(mousePos.x, 0, mousePos.y)

22
Scenes/Scripts/Camera.gd Normal file
View file

@ -0,0 +1,22 @@
extends Camera
export var scaleFactor := 0.2
export var animSpeed := 20
var targetZoom := 0.0
var currentZoom := 0.0
func zoom(inward: bool):
var direction := 1
if !inward:
direction *= -1
targetZoom += scaleFactor * direction
func _process(delta: float):
if abs(targetZoom - currentZoom) > 0:
var deltaZoom := (targetZoom - currentZoom) * (delta * animSpeed)
transform = transform.translated(Vector3.FORWARD * deltaZoom)
currentZoom += deltaZoom
func getZoomLevel() -> float:
return currentZoom

View file

@ -1,15 +0,0 @@
extends Control
func _input(event: InputEvent):
if event.is_action_pressed("zoom_in"):
zoom(true)
elif event.is_action_pressed("zoom_out"):
zoom(false)
const SCALE_FACTOR := 0.1
func zoom(direction: bool):
var scaleFactor := 1 + SCALE_FACTOR
if not direction:
scaleFactor = 1 - SCALE_FACTOR
$Board.scale *= scaleFactor

View file

@ -37,6 +37,12 @@ zoom_out={
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":5,"pressed":false,"doubleclick":false,"script":null)
]
}
pan={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null)
]
}
[rendering]