Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions public/usage-examples/graphics/draw_circle-2-animation.cpp

This comment was marked as resolved.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "splashkit.h"

using namespace splashkit;

int main()
{
open_window("Circle Animation", 800, 600);

double x = 0;

while (!window_close_requested("Circle Animation"))
{
process_events();
clear_screen(COLOR_WHITE);

draw_circle(COLOR_RED, x, 300, 50);

x += 2;
if (x > 800) x = 0;

refresh_screen(60);
}

return 0;
}
17 changes: 17 additions & 0 deletions public/usage-examples/graphics/draw_circle-2-animation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from splashkit import *

open_window("Circle Animation", 800, 600)

x = 0

while not window_close_requested("Circle Animation"):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argument of window_close_requested should be the window object (returned from open_window earlier)

process_events()
clear_screen(Color.WHITE)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Color.WHITE does not exist in SplashKit's Python; you might need to use color_white() or, instead of the entire function, use clear_screen_to_white()


draw_circle(Color.RED, x, 300, 50)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First argument is invalid, as Color.RED does not exist; you might need to use color_red() instead


x += 2
if x > 800:
x = 0

refresh_screen(60)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refresh_screen in Python does not take arguments; you can use refresh_screen_with_target_fps for the same purposes

1 change: 1 addition & 0 deletions public/usage-examples/graphics/draw_circle-2-animation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Animate a circle moving across the screen
29 changes: 29 additions & 0 deletions public/usage-examples/graphics/draw_circle-3-interactive.cpp

This comment was marked as resolved.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Move a circle using arrow keys
#include "splashkit.h"

using namespace splashkit;

int main()
{
open_window("Interactive Circle", 800, 600);

double x = 400;
double y = 300;

while (!window_close_requested("Interactive Circle"))
{
process_events();
clear_screen(COLOR_WHITE);

if (key_down(LEFT_KEY)) x -= 5;
if (key_down(RIGHT_KEY)) x += 5;
if (key_down(UP_KEY)) y -= 5;
if (key_down(DOWN_KEY)) y += 5;

draw_circle(COLOR_BLUE, x, y, 50);

refresh_screen(60);
}

return 0;
}
25 changes: 25 additions & 0 deletions public/usage-examples/graphics/draw_circle-3-interactive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Move a circle using arrow keys

from splashkit import *

open_window("Interactive Circle", 800, 600)

x = 400
y = 300

while not window_close_requested("Interactive Circle"):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window_close_requested takes the result of open_window as an argument

process_events()
clear_screen(Color.WHITE)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Color.WHITE does not exist in Splashkit's Python


if key_down(KeyCode.LEFT_KEY):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeyCode.LEFT_KEY does not exist, you might need to use KeyCode.left_key instead; similar issue perists at lines 16, 18, 20

x -= 5
if key_down(KeyCode.RIGHT_KEY):
x += 5
if key_down(KeyCode.UP_KEY):
y -= 5
if key_down(KeyCode.DOWN_KEY):
y += 5

draw_circle(Color.BLUE, x, y, 50)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Color.BLUE does not exist in Python, you might need to use color_blue() instead


refresh_screen(60)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function does not take arguments, use refresh_screen_with_target_fps() to set the speed of refresh

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move a circle using arrow keys to demonstrate interactive usage of draw_circle.