-
Notifications
You must be signed in to change notification settings - Fork 1
Drawing an image
Ryan G edited this page Sep 18, 2017
·
1 revision
Shapes are all well and good, but most games require images: your character, your backgrounds, etc. To draw an image we first need to add one. Download this image and place it in the root of your project as "ball.png"
import dgt;
void main()
{
Window window = Window("Your First Window", 800, 600, WindowConfig());
Texture ball = Texture("ball.png");
while(window.isOpen)
{
window.begin(Color.white);
window.draw(ball, 400, 300);
window.end();
}
}
You should now see the ball image near the middle of your window.
window.draw(ball, 400, 300); draws the image ball with the top left at the x position 400 and the y position 300.