CSharp · Console
using System;
using System.Collections.Generic;
public interface Actionable{
void Do();
}
public interface Drawable{
void Draw();
}
public class Player : Drawable, Actionable{
public void Do(){
Console.WriteLine("Action");
}
public void Draw(){
Console.WriteLine("Draw");
}
}
public class Program
{
public delegate void DrawHandler(IEnumerable<Drawable> obj);
public delegate void LogicHandler(IEnumerable<Actionable> obj);
public static void gameloop(DrawHandler draw,LogicHandler action){
List<Player> list = new List<Player>(){
new Player()
};
for(int rounds = 0; rounds < 500; rounds++){
draw(list);
action(list);
}
}
public static void Main()
{
gameloop(
list =>{
foreach(var item in list){
item.Draw();
}
},
list =>{
foreach(var item in list){
item.Do();
}
}
);
}
}