Code repository for HSCI-234: Computer Science for Designers & Artists.
Examples below can be viewed and run on GitHub Pages at:
https://pa-nik.github.io/SP23-HSCI-234/
Editing files on GitHub - how to edit files in your repository
Creating a GitHub Pages site - how to deploy your repository as a website
raw.githack.com - use this site to immediately preview your index.html
(raw version) by replacing raw.githubusercontent.com in the URL with raw.githack.com
p5.js Reference - this reference uses the JavaScript syntax, but usage is almost the same in PyScript, just add p5.
at the beginning of each function name or p5 variable.
PyScript + P5 - new p5 library template including event functions
Hello Python! - PyScript terminal (REPL)
Begin P5 - blank p5 library template
2.1 Basic Shapes - drawing geometric shapes
2.2 Shapes Properties - stroke weight, cap, join properties
2.3 Colors - fill and stroke colors
2.4 Drawing with Variables - variables in drawing functions
In-Class Practice - in-class practice examples
Glossary - computer science terms
3.1 Built-in p5 Variables - p5.width
, p5.height
, p5.mouseX
, p5.mouseY
variables
3.2 Random Function - using randomness
3.3 Transformation Functions - using transformations like translate, rotate, scale
3.4 Defining Functions - how to define and call functions
In-Class Practice - in-class practice examples
Flower Exercise - drawing with transformations, functions and repetition
Glossary
4.1 Global Variables - using global variables
4.2 Conditionals - conditions, relational and logical operators
4.3 Mouse Conditions - conditions with p5.mouseIsPressed
, p5.mouseButton
4.4 Key Conditions - conditions with p5.keyIsPressed
, p5.key
, p5.keyCode
In-Class Practice (Terminal)
In-Class Practice (p5)
Glossary
5.1 Function Return Value - using function return
statement
5.2 Button Functions - creating buttons with functions and return values
Pong V1 - version 1 of Pong game
In-Class Practice
Glossary
6.1 Event Functions - using events like mousePressed()
, keyPressed()
, etc.
6.2 Program State - using state machine for program behavior
6.3 Timing - using p5.millis()
function for timing
Pong V2 - Pong game with program state and timer
In-Class Practice
7.1 Object Attributes - using objects and their attributes
7.2 Object Methods - using objects methods
7.3 Initializing Objects - using the __init__
method to initialize objects
In-Class Practice
Traffic Light Exercise
Glossary
8.1 Drawing Images - using p5.loadImage
, p5.image
functions
8.2 Drawing Text - using p5.loadFont
, p5.textFont
, p5.text
functions
8.3 Encapsulation & Abstraction - encapsulation and abstraction in OOP
Space Invaders V1 - version 1 of Space Invaders game
9.1 Inheritance & Polymorphism - inheritance and polymorphism in OOP
9.2 String as Sequence - using string sequence items, slicing and methods
9.3 List as Sequence - using lists, list slicing and methods
9.4 List of Objects - creating and manipulating a list of objects
In-Class Practice
10.1 while Loop - while
loop example
10.2 2D List - 2D list (list of lists) example
In-Class Practice
Space Invaders V2 - version 2 of Space Invaders game
Sound Example - using the p5.sound
library
Rotate to Cursor - angle to cursor using p5.atan2