Hi All, So, I'd like to say I've got a fair grasp of Nim, so I figured I'd try my hand at making a simple point and click game using Nim. I figured SDL2 would be good enough for the Graphics Library, but I have no experience using SDL2 otherwise. My programming experience is mostly with higher level, OOP languages like C# and a little of Java. My experience with C++ is very elementary. Here is the code I'm trying to implement in Nim's SDL2:
SDL_Rect fillRect = { SCREEN_WIDTH / 4, SCREEN_HEIGHT / 4, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 };
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0x00, 0x00, 0xFF );
SDL_RenderFillRect( gRenderer, &fillRect );
Nim's Rect is like this:
Rect* = tuple[x, y: cint, w, h: cint]
and the fillRect code:
proc fillRect*(renderer: RendererPtr; rect: var Rect): SDL_Return {.
importc: "SDL_RenderFillRect", discardable.}
proc fillRect*(renderer: RendererPtr; rect: ptr Rect = nil): SDL_Return {.
importc: "SDL_RenderFillRect", discardable.}
Can anyone help me translating this? Thanks, hcorionHaven't tested this (on my phone):
var fillRect = Rect(
x:cint(SCREEN_WIDTH/2), y:cint(SCREEN_HEIGHT/2),
w:cint(SCREEN_WIDTH/2), h:cint(SCREEN_HEIGHT/2)
)
setRenderDrawColor(gRenderer, 0xFF'i32, 0x00'i32, 0x00'i32, 0xFF'i32)
fillRect(gRenderer, fillRect)