Skip to content

Commit

Permalink
c# BABY
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor greene committed Sep 22, 2021
1 parent 950c22c commit 9b448f6
Show file tree
Hide file tree
Showing 30 changed files with 191 additions and 29 deletions.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"configurations": [

{
"type": "godot",
"request": "launch",
"project": "",
"port": 6007,
"address": "127.0.0.1",
"launch_game_instance": true,
"launch_scene": false
}
]
}
Binary file added Build/Linux/Linux.zip.x86_64
Binary file not shown.
Binary file added Build/MacOS/Macos.zip
Binary file not shown.
Binary file added Build/Windows/Windows.exe
Binary file not shown.
15 changes: 15 additions & 0 deletions Prefabs/ColorFilter.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extends ColorRect


func _ready():
self.get_viewport().connect("change_filter_size",self,"size_changed")
pass # Replace with function body.

func _process(delta):

if(self.get_parent().get_parent().is_in_water()):
self.set_size(self.get_viewport().size)
self.material.set_shader_param ( "use_shader", true )
else:
self.material.set_shader_param ( "use_shader", false )

12 changes: 6 additions & 6 deletions Prefabs/IslandTerrain.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=6 format=2]

[ext_resource path="res://Scripts/IslandTerrain.gd" type="Script" id=1]
[ext_resource path="res://Scripts/IslandTerrainCreator.cs" type="Script" id=1]
[ext_resource path="res://assets/maujoe.basic_water_material/textures/water_normal_1.png" type="Texture" id=2]

[sub_resource type="CubeMesh" id=1]
Expand Down Expand Up @@ -90,11 +90,11 @@ void fragment(){

[sub_resource type="ShaderMaterial" id=3]
shader = SubResource( 2 )
shader_param/beer_factor = 0.8
shader_param/foam_distance = 0.01
shader_param/foam_max_distance = 0.4
shader_param/foam_min_distance = 0.04
shader_param/foam_color = Color( 1, 1, 1, 1 )
shader_param/beer_factor = 1.0
shader_param/foam_distance = 0.0
shader_param/foam_max_distance = 0.0
shader_param/foam_min_distance = 0.0
shader_param/foam_color = Color( 1, 1, 1, 0 )
shader_param/surface_noise_tiling = Vector2( 1, 4 )
shader_param/surface_noise_scroll = Vector3( 0.03, 0.03, 0 )
shader_param/surface_noise_cutoff = 1.0
Expand Down
24 changes: 22 additions & 2 deletions Prefabs/Player.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=10 format=2]

[ext_resource path="res://Scripts/Player.gd" type="Script" id=1]
[ext_resource path="res://Prefabs/ColorFilter.gd" type="Script" id=2]
[ext_resource path="res://Resources/vignette.png" type="Texture" id=3]

[sub_resource type="CapsuleMesh" id=1]
radius = 0.5
Expand All @@ -19,13 +21,30 @@ height = 0.465248
[sub_resource type="Shader" id=5]
code = "shader_type canvas_item;

uniform bool use_shader = false;

uniform sampler2D vignette;

void fragment(){
vec4 bg = texture(SCREEN_TEXTURE,SCREEN_UV);
COLOR = vec4(bg.r,bg.g,bg.b,1f);

if(use_shader){
vec3 vignette_color = texture(vignette, UV).rgb;
// Screen texture stores gaussian blurred copies on mipmaps.
COLOR.rgb = textureLod(SCREEN_TEXTURE, SCREEN_UV, (1.0 - vignette_color.r) * 4.0).rgb;
COLOR.rgb *= texture(vignette, UV).rgb;
//vec4(bg.r/1.5f,bg.g/1.5f,bg.b,1f) -

COLOR += vec4(bg.r/2.5f,bg.g/2.5f,bg.b,1f);
}else{
COLOR = bg;
}
}"

[sub_resource type="ShaderMaterial" id=6]
shader = SubResource( 5 )
shader_param/use_shader = false
shader_param/vignette = ExtResource( 3 )

[node name="Player" type="KinematicBody"]
script = ExtResource( 1 )
Expand Down Expand Up @@ -68,6 +87,7 @@ material/0 = null
material = SubResource( 6 )
margin_right = 1029.0
margin_bottom = 605.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
Binary file added Resources/vignette.png
Loading
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 Resources/vignette.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

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

[deps]

source_file="res://Resources/vignette.png"
dest_files=[ "res://.import/vignette.png-d139b46f79c1712950634ae6916e799a.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=2
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=false
svg/scale=1.0
15 changes: 10 additions & 5 deletions Scenes/DEV.tscn
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
[gd_scene load_steps=4 format=2]

[sub_resource type="CylinderMesh" id=1]
height = 7.909
[sub_resource type="CubeMesh" id=1]

[sub_resource type="Shader" id=2]
code = "shader_type canvas_item;
code = "shader_type spatial;



void fragment(){
COLOR = vec4(UV.x,0,0,1);

vec4 wrld_vertex = CAMERA_MATRIX * vec4(VERTEX, 1.0f);

ALBEDO = vec3(wrld_vertex.x,wrld_vertex.y,wrld_vertex.z);

}"

[sub_resource type="ShaderMaterial" id=3]
Expand All @@ -16,6 +21,6 @@ shader = SubResource( 2 )
[node name="Spatial" type="Spatial"]

[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.309697, 3.48917, -0.780013 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.67777, 5.00796, -1.39269 )
mesh = SubResource( 1 )
material/0 = SubResource( 3 )
10 changes: 5 additions & 5 deletions Scenes/Menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ margin_left = 226.455
margin_top = 177.694
margin_right = 807.455
margin_bottom = 191.694
text = "Dev Build 0.1.3"
text = "Dev Build 1.0.2"
align = 1
__meta__ = {
"_edit_use_anchors_": false
Expand All @@ -75,10 +75,10 @@ __meta__ = {

[node name="Label" type="Label" parent="."]
material = SubResource( 5 )
margin_left = 404.356
margin_top = 309.72
margin_right = 644.356
margin_bottom = 369.72
margin_left = 399.571
margin_top = 310.777
margin_right = 639.571
margin_bottom = 370.777
custom_fonts/font = SubResource( 6 )
text = "Loading..."
__meta__ = {
Expand Down
1 change: 1 addition & 0 deletions Scripts/IslandTerrain.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ func _ready():


func generate_island():
#OLD CODE DONT USE
randomize()

var surface_tool = SurfaceTool.new()
Expand Down
80 changes: 80 additions & 0 deletions Scripts/IslandTerrainCreator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using Godot;
using System;

public class IslandTerrainCreator : Spatial
{
const int SIZE = 320;

public override void _Ready()
{
generate_island();
}

public void generate_island(){
GD.Print("Starting Making Island");
GD.Randomize();

//Setup Tools needed
SurfaceTool surface_tool = new SurfaceTool();
MeshDataTool mesh_data_tool = new MeshDataTool();
OpenSimplexNoise noise = new OpenSimplexNoise();
//Setup Plane Mesh
PlaneMesh plane_mesh = new PlaneMesh();
plane_mesh.Size = new Vector2(SIZE,SIZE);
plane_mesh.SubdivideDepth = SIZE / 2;
plane_mesh.SubdivideWidth = SIZE / 2;
//Setup Noise
Random rng = new Random();
noise.Seed = rng.Next(0,2147483640);
noise.Octaves = 5;
noise.Period = 120;
//TODO find out what this code does again
surface_tool.CreateFrom(plane_mesh,0);
ArrayMesh array_mesh = surface_tool.Commit();
mesh_data_tool.CreateFromSurface(array_mesh,0);

//Do some CRAZY math to make the hilly terrain a island
Vector2 radius = (new Vector2(1.0f - SIZE - 1,1.0f - SIZE - 1)) / 2;
float ratio = (SIZE-1 / SIZE-1);

//Make Terrain
for(int i = 0;i <= mesh_data_tool.GetVertexCount() - 1; i++){
Vector3 vertux = mesh_data_tool.GetVertex(i);
float value = noise.GetNoise3d(vertux.x,vertux.y,vertux.z);

float dist = new Vector2(0,0).DistanceTo(new Vector2(vertux.x, vertux.z));
float ofs = dist / radius.y;

value += ofs;

vertux.y = (value * 50);

vertux.y -= 23;



mesh_data_tool.SetVertex(i,vertux);

}

for(int s = 0; s <= array_mesh.GetSurfaceCount();s++){
array_mesh.SurfaceRemove(s);
}
mesh_data_tool.CommitToSurface(array_mesh);
surface_tool.Begin(Mesh.PrimitiveType.Triangles);
surface_tool.CreateFrom(array_mesh,0);
surface_tool.GenerateNormals();

SpatialMaterial material = new SpatialMaterial();
MeshInstance meshInstance = new MeshInstance();
meshInstance.Mesh = surface_tool.Commit();
meshInstance.CreateTrimeshCollision();
material.AlbedoColor = new Color(0x640000);
meshInstance.MaterialOverride = material;

this.AddChild(meshInstance);

//this.GetNode("WaterLevel").

}
}
12 changes: 2 additions & 10 deletions Scripts/StartGame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,11 @@ func _ready():

func _button_pressed():
#When button is pressed start loading Island!
self.text = 'Loading...'
self.hide();

self.get_parent().get_child(3).show()
load_scene();


thread = Thread.new()
thread.start(self,"_load_scene","sus")


func _load_scene(data):
func load_scene():

get_tree().change_scene("res://Scenes/Game.tscn")

func _exit_tree():
thread.wait_to_finish()
Binary file added mono_crash.mem.32276.1.blob
Binary file not shown.
Binary file added mono_crash.mem.32276.7f21bde93700.blob
Binary file not shown.
Binary file added mono_crash.mem.32276.7f21cc3fe700.blob
Binary file not shown.
Binary file added mono_crash.mem.32276.7f221d55b5c0.blob
Binary file not shown.
Binary file added mono_crash.mem.32374.1.blob
Binary file not shown.
Binary file added mono_crash.mem.32374.7f609257f700.blob
Binary file not shown.
Binary file added mono_crash.mem.32374.7f60aa7fc700.blob
Binary file not shown.
Binary file added mono_crash.mem.32765.1.blob
Binary file not shown.
Binary file added mono_crash.mem.32765.7f9d93fff700.blob
Binary file not shown.
Binary file added mono_crash.mem.32765.7f9dbc3ff700.blob
Binary file not shown.
Binary file added mono_crash.mem.32765.7f9df7b695c0.blob
Binary file not shown.
Binary file added mono_crash.mem.32957.1.blob
Binary file not shown.
Binary file added mono_crash.mem.32957.7ff50dc93700.blob
Binary file not shown.
Binary file added mono_crash.mem.32957.7ff51c3fe700.blob
Binary file not shown.
Empty file.
3 changes: 2 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ _global_script_class_icons={

config/name="Islanders.io"
run/main_scene="res://Scenes/Menu.tscn"
boot_splash/bg_color=Color( 0.282353, 0, 0.427451, 1 )
config/icon="res://icon.png"

[display]

window/size/test_width=1024
window/size/test_height=600
window/stretch/aspect="expand"

[input]

Expand Down Expand Up @@ -68,4 +68,5 @@ common/enable_pause_aware_picking=true

[rendering]

threads/thread_model=2
environment/default_environment="res://default_env.tres"

0 comments on commit 9b448f6

Please sign in to comment.