-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic pygame for use with local Jupyter
- Loading branch information
Showing
2 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
# jupyter-notebooks | ||
# Notebooks | ||
|
||
A collection of notebooks for use with Jupyter or VSCode | ||
|
||
## Contens | ||
|
||
* `pygame` | ||
|
||
|
||
Authors | ||
------- | ||
|
||
| [!["Gerard Braad"](http://gravatar.com/avatar/e466994eea3c2a1672564e45aca844d0.png?s=60)](http://gbraad.nl "Gerard Braad <[email protected]>") | | ||
|---| | ||
| [@gbraad](https://gbraad.nl/social) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Defaulting to user installation because normal site-packages is not writeable\n", | ||
"Collecting pygame\n", | ||
" Downloading pygame-2.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.7 MB)\n", | ||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.7/13.7 MB\u001b[0m \u001b[31m86.0 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:04\u001b[0m\n", | ||
"\u001b[?25hInstalling collected packages: pygame\n", | ||
"Successfully installed pygame-2.2.0\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"!pip install pygame" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"pygame 2.2.0 (SDL 2.0.22, Python 3.11.1)\n", | ||
"Hello from the pygame community. https://www.pygame.org/contribute.html\n" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"(5, 0)" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import pygame\n", | ||
"pygame.init()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pygame.display.init()\n", | ||
"run=True\n", | ||
"\n", | ||
"screensize = (width,height)=(600,600)\n", | ||
"screen = pygame.display.set_mode(screensize)\n", | ||
"myfont = pygame.font.SysFont('Arial', 30)\n", | ||
"\n", | ||
"while run:\n", | ||
" pygame.time.delay(20)\n", | ||
" for event in pygame.event.get():\n", | ||
" if event.type == pygame.QUIT:\n", | ||
" run=False \n", | ||
" screen.fill((0,0,0))\n", | ||
"\n", | ||
" textsurface = myfont.render(str(\"Hello, World!\"), False, \"white\")\n", | ||
" screen.blit(textsurface,(220,300))\n", | ||
"\n", | ||
" pygame.display.update()\n", | ||
"\n", | ||
"pygame.display.quit()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.1" | ||
}, | ||
"orig_nbformat": 4, | ||
"vscode": { | ||
"interpreter": { | ||
"hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a" | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |