Commit 5b73f3db authored by horle's avatar horle
Browse files

merge

parents 3e315989 c67523e0
[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
......@@ -99,6 +99,7 @@ public class TileMap : Godot.TileMap
public override void _Ready()
{
mapInstance.resetBrett(new Vector2(20, 20), new Vector2[2] {new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f)});
DrawFields();
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
......@@ -107,14 +108,74 @@ public class TileMap : Godot.TileMap
if(Input.IsActionPressed("game_select"))
{
Vector2 vector = WorldToMap(GetGlobalMousePosition());
SetCellv(vector, 8);
mapInstance.stellDunger(0, vector - new Vector2(0.5f, 0.5f));
DrawFields();
}
if(Input.IsActionPressed("game_rightclick"))
{
Vector2 vector = WorldToMap(GetGlobalMousePosition());
SetCellv(vector, 13);
mapInstance.stellBarriere(vector - new Vector2(0.5f, 0.5f));
DrawFields();
}
spieler2.schritt(delta);
Sprite p = (Sprite) GetNode("Maus");
p.Position = spieler2.wobinich();
Sprite sp = (Sprite) GetNode("Sprite2");
// Wir wollen schrittweise Bewegung
sp.Position = MapToWorld(WorldToMap(p.Position));
}
private enum TileTypes
{
None = -1,
Grass = 0,
Dunger1 = 8,
Dunger2,
DungerZusammen,
Baum = 10,
Schleim = 11,
Barriere = 13
}
private void DrawFields()
{
for(int y = 0; y < mapInstance.grosse().y; y++)
{
for(int x = 0; x < mapInstance.grosse().x; x++)
{
if(mapInstance.hat_spieler(0, new Vector2(x, y)))
{
SetCellv(new Vector2(x, y), (int)TileTypes.Baum);
}
else if (mapInstance.hat_spieler(1, new Vector2(x, y)))
{
SetCellv(new Vector2(x, y), (int)TileTypes.Schleim);
}
else if (mapInstance.hat_dunger(0, new Vector2(x, y)) || mapInstance.hat_dunger(1, new Vector2(x, y)))
{
if(mapInstance.hat_dunger(0, new Vector2(x, y)) && mapInstance.hat_dunger(1, new Vector2(x, y)))
{
SetCellv(new Vector2(x, y), (int)TileTypes.DungerZusammen);
}
else if(mapInstance.hat_dunger(0, new Vector2(x, y)))
{
SetCellv(new Vector2(x, y), (int)TileTypes.Dunger1);
}
else if (mapInstance.hat_dunger(1, new Vector2(x, y)))
{
SetCellv(new Vector2(x, y), (int)TileTypes.Dunger2);
}
}
else if (mapInstance.hat_barriere(new Vector2(x, y)))
{
SetCellv(new Vector2(x, y), (int)TileTypes.Barriere);
}
else
{
SetCellv(new Vector2(x, y), (int)TileTypes.Grass);
}
}
}
spieler2.schritt(delta);
......@@ -135,9 +196,44 @@ public class TileMap : Godot.TileMap
Sprite sp = (Sprite) GetNode("Sprite");
sp.Position = MapToWorld(vector);
}
if (ev is InputEventKey key && key.Pressed) {
if (ev is InputEventKey key && key.Pressed && key.Scancode == 32)
{
mapInstance.verbreitenSpieler(0);
mapInstance.verbreitenSpieler(1);
}
if (ev is InputEventKey key2 && key2.Pressed) {
//eventKey.Pressed && eventKey.Scancode == (int)KeyList.Escape
Print("test: "+ key.Scancode);
Print("test: "+ key2.Scancode);
}
if (Input.IsActionPressed("ui_right")) {
spieler2.jetztRechts();
} else {
spieler2.jetztRechtsStopp();
}
if (Input.IsActionPressed("ui_down")) {
spieler2.jetztUnten();
} else {
spieler2.jetztUntenStopp();
}
if (Input.IsActionPressed("ui_left")) {
spieler2.jetztLinks();
} else {
spieler2.jetztLinksStopp();
}
if (Input.IsActionPressed("ui_up")) {
spieler2.jetztOben();
} else {
spieler2.jetztObenStopp();
}
// noch Spieler 2
if (Input.IsActionJustPressed("arrows_select")) {
Vector2 v = WorldToMap(MapToWorld((spieler2.wobinich())));
mapInstance.stellDunger(1, v - new Vector2(0.5f, 0.5f));
}
if (Input.IsActionJustPressed("arrows_alternate")) {
Vector2 v = WorldToMap(MapToWorld((spieler2.wobinich())));
mapInstance.stellBarriere(v - new Vector2(0.5f, 0.5f));
}
if (Input.IsActionPressed("ui_right")) {
spieler2.jetztRechts();
......
......@@ -36,6 +36,21 @@ class Brushable : BitMap {
}
class Bitwise : Brushable {
public Bitwise duplicate() {
Vector2 size = GetSize();
Bitwise b = new Bitwise();
b.Create(size);
for (int x = 0; x < size.x; x++) {
for (int y = 0; y < size.y; y++) {
Vector2 pxpos = new Vector2(x, y);
bool bit = GetBit(pxpos);
SetBit(pxpos, bit);
}
}
return b;
}
public Bitwise and(BitMap other) {
Vector2 size = GetSize();
Bitwise b = new Bitwise();
......@@ -166,14 +181,20 @@ public class map : Node2D
Vector2 m = spieler[spielerIdx].GetSize();
Bitwise unerlaubt = spieler[-spielerIdx + 1].or(barrieren);
Bitwise erlaubt = dunger[spielerIdx].and_not(unerlaubt);
Bitwise neu_stand = (Bitwise)spieler[spielerIdx].Duplicate(true);
Bitwise neu_stand = spieler[spielerIdx].duplicate();
while (wachstumbudget > 0) {
neu_stand.GrowMask(wachsengeschwindigkeit, new Rect2(n, m));
Bitwise wachstum = neu_stand.and(erlaubt);
for (int i = 0; i < wachstum.GetTrueBitCount() - wachstumbudget; i++) {
// zufallig einen von wachstum von 1 zu 0 stellen
break;
}
wachstumbudget -= wachstum.GetTrueBitCount();
if (wachstum.GetTrueBitCount() <= 0) {
break; // Irgendwie blockiert. Ende Spiel?
}
break;
}
spieler[spielerIdx] = neu_stand;
}
......@@ -212,7 +233,7 @@ public class map : Node2D
return spieler[spielerIdx].GetBit(platz);
}
public bool hat_barriere(int spielerIdx, Vector2 platz) {
public bool hat_barriere(Vector2 platz) {
return barrieren.GetBit(platz);
}
// Declare member variables here. Examples:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment