Task

Create a window and draw a pixel in it, subject to the following:

  the window is 320 x 240
  the color of the pixel must be red (255,0,0)
  the position of the pixel is x = 100, y = 100
use Game.SDL2;
use Game.Framework;
 
class DrawPixel {
  @framework : GameFramework;
 
  function : Main(args : String[]) ~ Nil {
    DrawPixel->New()->Run();
  }
 
  New() {
    @framework := GameFramework->New(320, 240, "RGB");
    @framework->SetClearColor(Color->New(0, 0, 0));
  }
 
  method : Run() ~ Nil {
    if(@framework->IsOk()) {
      e := @framework->GetEvent();
 
      quit := false;
      while(<>quit) {
        @framework->FrameStart();
        @framework->Clear();
 
        while(e->Poll() <> 0) {
          if(e->GetType() = EventType->SDL_QUIT) {
            quit := true;
          };
        };
 
        @framework->GetRenderer()->SetDrawColor(255, 0, 0, 255);
        @framework->GetRenderer()->DrawPoint(100, 100);  
 
        @framework->Show();
        @framework->FrameEnd();
      };
    }
    else {
      "--- Error Initializing Game Environment ---"->ErrorLine();
      return;
    };
 
    leaving {
      @framework->Quit();
    };
  }
}
 