Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ceeplusplus

Pages: [1]
1
Graphics / Draw shape function
« on: April 01, 2020, 11:03:25 pm »
I have this chunk of code that draws a square:

RectangleShape rect (Vector2f(100.f, 100.f));
rect.setFillColor(Color(100, 50, 200));
rect.setPosition(50.f, 50.f);
window.draw(rect);

I want to have some kind of function/class that does this.  The problem I'm having is that when I put this into a function, it doesn't work anymore, because the "window" object is declared inside of main{}.  Is there a way I can pass in the renderwindow from main{} to a function?

full code:
(click to show/hide)

p.s. i'm very new to cpp development, i might be asking the wrong question

Pages: [1]