updated publish

This commit is contained in:
MasterGordon 2022-10-05 17:22:06 +02:00
parent c2f5b9bde9
commit 6a982bf8d7
5 changed files with 51 additions and 1 deletions

View File

@ -5,6 +5,9 @@
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>asdlteroids</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
<Nullable>enable</Nullable>
</PropertyGroup>

View File

@ -10,6 +10,7 @@ class Scene
private Renderer renderer;
private static Scene? instance;
public Ufo ufo;
public HashSet<Shot> Shots;
public HashSet<Asteroid> Asteroids;
public int Score = 0;
@ -20,6 +21,7 @@ class Scene
public Scene(Renderer renderer)
{
this.ship = new Ship(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
this.ufo = new Ufo(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
this.ui = new UI();
this.Shots = new HashSet<Shot>();
this.Asteroids = new HashSet<Asteroid>();
@ -54,6 +56,7 @@ class Scene
var entities = new List<Object>();
entities.Add(ship);
entities.Add(ui);
// entities.Add(ufo);
entities.AddRange(Shots);
entities.AddRange(Asteroids);

View File

@ -9,7 +9,7 @@ class KeyState
{
var origArray = SDL_GetKeyboardState(out var arraySize);
this.keys = new byte[arraySize];
Marshal.Copy(origArray, keys, 0, arraySize);
Marshal.Copy(origArray, this.keys, 0, arraySize);
}
public bool isPressed(SDL_Keycode keycode)

View File

@ -59,5 +59,7 @@ class UI : Renderable
}
SDL_RenderCopy(renderer.GetRaw(), texture, IntPtr.Zero, ref rect);
SDL_DestroyTexture(texture);
SDL_FreeSurface(surfaceMessage);
}
}

42
src/entities/Ufo.cs Normal file
View File

@ -0,0 +1,42 @@
class Ufo : Logic, Renderable
{
public int X, Y;
public Ufo(int x, int y)
{
X = x;
Y = y;
}
public void Render(Renderer renderer, double dx)
{
renderer.setColor(255, 255, 255);
renderer.DrawLines(new double[][]{
new double[]{X-Scene.SCALE*15, Y},
new double[]{X+Scene.SCALE*15, Y},
});
renderer.DrawLines(new double[][]{
new double[]{X-Scene.SCALE*15, Y},
new double[]{X-Scene.SCALE*6, Y+Scene.SCALE*6},
new double[]{X+Scene.SCALE*6, Y+Scene.SCALE*6},
new double[]{X+Scene.SCALE*15, Y},
});
renderer.DrawLines(new double[][]{
new double[]{X-Scene.SCALE*15, Y},
new double[]{X-Scene.SCALE*6, Y-Scene.SCALE*6},
new double[]{X+Scene.SCALE*6, Y-Scene.SCALE*6},
new double[]{X+Scene.SCALE*15, Y},
});
renderer.DrawLines(new double[][]{
new double[]{X-Scene.SCALE*6, Y-Scene.SCALE*6},
new double[]{X-Scene.SCALE*4, Y-Scene.SCALE*12},
new double[]{X+Scene.SCALE*4, Y-Scene.SCALE*12},
new double[]{X+Scene.SCALE*6, Y-Scene.SCALE*6},
});
}
public void Update(KeyState keyState, double dx)
{
//
}
}