[JsonObject("MapDataModel")]
public class MapData
{
[JsonProperty("list")]
public List[] list { get; set; }
}
[JsonObject("List")]
public class List
{
[JsonProperty("name")]
public string name { get; set; }
[JsonProperty("point")]
public Point[] point { get; set; }
}
[JsonObject("Point")]
public class Point
{
[JsonProperty("x")]
public int x { get; set; }
[JsonProperty("y")]
public int y { get; set; }
}
class FileAccess
{
private const string _filename = "hokkaido.json";
public static MapData Load()
{
string str = string.Empty;
using (var stream = new StreamReader(_filename, true))
{
str = stream.ReadToEnd();
}
return JsonConvert.DeserializeObject<MapData>(str);
}
}
これをAltseedで画面に表示させます。
class HokkaidoWar
{
MapData mapData = null;
public HokkaidoWar()
{
mapData = FileAccess.Load();
}
public void Run()
{
asd.Engine.Initialize("北海道大戦", 1800, 1000, new asd.EngineOption());
// 下地
var background = new asd.GeometryObject2D();
asd.Engine.AddObject2D(background);
var bgRect = new asd.RectangleShape();
bgRect.DrawingArea = new asd.RectF(0, 0, 1800, 1000);
background.Shape = bgRect;
var r = new Random();
foreach (var map in mapData.list)
{
var color = new asd.Color((byte)r.Next(0, 255), (byte)r.Next(0, 255), (byte)r.Next(0, 255));
foreach (var point in map.point)
{
var geometryObj = new asd.GeometryObject2D();
geometryObj.Color = color;
asd.Engine.AddObject2D(geometryObj);
var rect = new asd.RectangleShape();
rect.DrawingArea = new asd.RectF(24 * point.x + 50, 24 * point.y + 50, 24, 24);
geometryObj.Shape = rect;
}
}
while (asd.Engine.DoEvents())
{
asd.Engine.Update();
}
asd.Engine.Terminate();
}
}
def GLCDBox(Xp0, Yp0, Xp1, Yp1):
for i in range(Xp0, Xp1 + 1):
GLCDPutPixel(i, Yp0)
GLCDPutPixel(i, Yp1)
for i in range(Yp0 + 1, Yp1):
GLCDPutPixel(Xp0, i)
GLCDPutPixel(Xp1, i)
def GLCDPutPixel(Xp, Yp):
#ラインの選択処理
L = 1 << (Yp % 8)
#LCDに表示するアドレスの位置をセットする
SetLocation(Xp, Yp)
#LCD画面の現在表示内容に指定位置のビット(L)をON(XOR)させ、そのデータをLCDに送る
L = ReadData() | L
SetAddress(SetCol)
WriteData(L)
def ReadData():
#データピンを入力に設定
for i in range(8):
GPIO.setup(DATA_p[i], GPIO.IN)
#読み込みモードにする
GPIO.output(RW_p, GPIO.HIGH)
GPIO.output(RS_p, GPIO.HIGH)
#データを読み込む
GPIO.output(E_p, GPIO.HIGH)
GPIO.output(E_p, GPIO.LOW)
ans = 0
GPIO.output(E_p, GPIO.HIGH)
for i in range(8):
ans = ans | (GPIO.input(DATA_p[i]) << i)
GPIO.output(E_p, GPIO.LOW)
#書き込みモードにする
GPIO.output(RW_p, GPIO.LOW)
#データピンを出力に設定
for i in range(8):
GPIO.setup(DATA_p[i], GPIO.OUT)
return ans
def ReadData():
#データピンを入力に設定
for i in range(8):
GPIO.setup(DATA_p[i], GPIO.IN)
#読み込みモードにする
GPIO.output(RW_p, GPIO.HIGH)
GPIO.output(RS_p, GPIO.HIGH)
#データを読み込む
GPIO.output(E_p, GPIO.HIGH)
time.sleep(EWAIT) #★
GPIO.output(E_p, GPIO.LOW)
ans = 0
GPIO.output(E_p, GPIO.HIGH)
time.sleep(EWAIT) #★
for i in range(8):
ans = ans | (GPIO.input(DATA_p[i]) << i)
GPIO.output(E_p, GPIO.LOW)
#書き込みモードにする
GPIO.output(RW_p, GPIO.LOW)
#データピンを出力に設定
for i in range(8):
GPIO.setup(DATA_p[i], GPIO.OUT)
return ans
def command(value, mode):
GPIO.output(RS_p, mode)
for i in range(8):
GPIO.output(DATA_p[i], (value >> i) & 0x01)
GPIO.output(E_p, GPIO.HIGH)
time.sleep(EWAIT) #★
GPIO.output(E_p, GPIO.LOW)