-
Notifications
You must be signed in to change notification settings - Fork 78
draw_circle usage examples (animation + interactive) #712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
6c7921d
d0c619a
790dcf2
18a94bb
9395f37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #include "splashkit.h" | ||
|
|
||
| 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; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| from splashkit import * | ||
|
|
||
| window = open_window("Circle Animation", 800, 600) | ||
|
|
||
| x = 0 | ||
|
|
||
| while not window_close_requested(window): | ||
| process_events() | ||
| clear_screen_to_white() | ||
|
|
||
| draw_circle(color_red(), x, 300, 50) | ||
|
|
||
| x += 2 | ||
| if x > 800: | ||
| x = 0 | ||
|
|
||
| refresh_screen_with_target_fps(60) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Animate a circle moving across the screen |
This comment was marked as resolved.
Sorry, something went wrong. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #include "splashkit.h" | ||
|
|
||
| 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; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| from splashkit import * | ||
|
|
||
| window = open_window("Interactive Circle", 800, 600) | ||
|
|
||
| x = 400 | ||
| y = 300 | ||
|
|
||
| while not window_close_requested(window): | ||
| process_events() | ||
| clear_screen_to_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_with_target_fps(60) | ||
| 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. |
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.