SlideShare a Scribd company logo
Introduction
to
coding
using JavaScript and codeguppy.com
Part I: Introduction
• About codeguppy.com
• Creating accounts in codeguppy.com
• Environment overview
Part II: Steps into coding
• Drag and drop coding
• Drawing with code
• Animations
Agenda
codeguppy.com
About codeguppy.com
• Online coding platform for kids, teens and
code newbies
• Text-based coding
• JavaScript language
• Based on p5.js (Processing API)
• Code animations, games and other fun
programs
• Built-in assets (backgrounds, sprites, etc.)
• Tons of projects. Browse – Remix – Share
• Free!
Why learn JavaScript?
• JavaScript is a super-popular real-world programming language
used both by beginners but also by professional software
developers. (The entire codeguppy.com was coded in JavaScript)
• People use JavaScript to build websites, online games and do
creative coding. On codeguppy.com, you can use JavaScript to draw
with code, implement animations, build games and other fun
projects.
• Coding in a text-based language such as JavaScript has also other
benefits beyond the world of programming. It enhances problem-
solving skills but also attention to details.
Programming is like
writing a book...
… except if you miss out a
single comma on page 349
the whole thing you wrote
makes no sense.
- Anonymous
codeguppy.com
Let’s open an account with codeguppy.com
• codeguppy.com gives you unlimited space in the cloud to write and
store tons of programs
• But first you need to open an account with codeguppy.com
• You need to provide a valid email address and a password (website
doesn’t ask any other personal details)
Note: After registration, you should get an email from codeguppy.com.
Please verify your email by clicking the link in the email.
JOIN FOR FREE
Email:
Password:
REGISTER NOW
Register with email
1
2
3
Code Editor
Type here your
program
Assets Toolbar
Browse sprite
library, colors,
etc.
Run / Stop Button
Run or Stop your program.
Output Canvas
Here you’ll see the
output of your
program.
Exploring
action bar
Let’s play with built-in assets
sprite('adventure_girl.idle', 400, 300, 0.5); sprite('knight.idle', 400, 300, 0.5);
You don’t have to write the above code. Just drag and drop a sprite from the palette in the code editor to have this code generated for you.
music('Fun Background');
background('Field');
sprite('plane.fly', 400, 300, 0.5);
Build a program using drag-and-drop
Step 1: Drag and drop a music
file
Step 2: Drag and drop a
background image or color
Step 3: Drag and drop a sprite
Press “Play” when ready.
Built-in instruction that asks
computer to display a sprite on
the canvas.
The actual sprite is specified in
between quotes inside the
parenthesis as a “parameter”.
Parameters of the instruction.
Parameters specify what sprite to display, where to
display it on the canvas and at what coordinates.
Experiment: Try to change the 400 and 300
numbers with other numbers between 0 and 800.
Press “Play” / “Stop”
after each
modification to run /
stop the program.
sprite('adventure_girl.idle', 400, 300, 0.5);
• Programs can write and draw on a graphical canvas of 800x600 pixels
• Origin is in the top-left corner
• Middle of the canvas is at about (400, 300)
• x coordinate goes from 0 to 800 (left to right)
• y coordinate goes from 0 to 600 (top to bottom)
(400, 300)
Output canvas
Our first type-in program
circle(400, 300, 300);
• Type carefully this line in the
code editor.
• Make sure you use the same
casing as illustrated and
include all the punctuation
signs.
• When ready, press the Play /
Run button
circle(400, 300, 300);
Built-in instruction that asks
computer to draw a circle on the
canvas.
codeguppy.com has many built-
in instructions for different
purposes (remember the sprite
instruction used before).
Parameters of the instruction.
There are 3 parameters inside
parenthesis and separated by comma:
- 400, 300 - coordinates of circle
center
- 300 – radius of the circle
Try to modify the
parameters of this
instruction and
notice the effect.
Don’t forget to press
“Play” / “Stop” after
each modification.
codeguppy.com/code.html
// Draw bear face
circle(400, 300, 200);
// Draw left ear
circle(250, 100, 50);
circle(270, 122, 20);
// Draw right ear
circle(550, 100, 50);
circle(530, 122, 20);
// Draw left eye
circle(300, 220, 30);
circle(315, 230, 10);
// Draw right eye
circle(500, 220, 30);
circle(485, 230, 10);
// Draw nose
circle(400, 400, 90);
circle(400, 350, 20);
Multiple instructions
in a program
Other graphical instructions
circle(400, 300, 200);
ellipse(400, 300, 300, 200);
rect(400, 300, 300, 200);
line(400, 300, 500, 500);
triangle(400, 100, 200, 400, 600, 500);
arc(400, 300, 300, 200, 0, 180);
point(400, 300);
text('JavaScript', 400, 300); JavaScript
(400, 300)
200
(400, 300)
300
200
(400, 300)
300
200
(400, 300)
(500, 500)
(200, 400) (600, 500)
(400, 100)
(400, 300)
(400, 300)
(400, 300)
Practicing graphical instructions
• Exercise 1: On a blank piece of paper
draw an object / scene using only basic
shapes such as circles, lines, rectangles.
Convert that drawing into code!
OR
• Exercise 2: Download the “Draw with
code” booklet from the downloads
section. Choose any drawing, print the
page and type-in the program.
Note: Programs from the “Draw with code” booklet may have more instructions then presented here. Try to discover their purpose.
Introducing variables
let r = 100;
let r2 = 100 - 4;
circle(100, 100, r);
circle(100, 100, r2);
OR
• JavaScript allows users to define variables to hold various values or the result of complex calculations
• You can name variables however you prefer… but don’t start them with number or weird symbols
• Variables are super important in programming
Expressions and variables instead of scalars
circle(100, 100, 100);
circle(100, 100, 96);
You can let the computer do
calculations. At the end of the
day, your computer is also a
powerful calculator.
circle(100, 100, 100);
circle(100, 100, 100 - 4);
let r2 = 100 – 4;
circle(100, 100, 100);
circle(100, 100, r2);
Building our own custom instructions
circle2();
function circle2()
{
circle(100, 100, 100);
circle(100, 100, 100 - 4);
}
• We placed the two circle
instructions inside a code block
(delimited by curly brackets)
• The block is the body of function
circle2. Notice carefully the
syntax.
• The function circle2 is our new
custom instructions. However,
exactly like circle, it doesn’t do
anything until we call it.
1
2
3
1
2
3
Functions with parameters
circle2(400, 300, 100);
function circle2(x, y, r)
{
circle(x, y, r);
circle(x, y, r - 4);
}
Now this is a useful
function! It can be used to
draw a double-circle on the
canvas.
We can control the
position and radius of the
double circle!
Exercise: Design your own custom instruction (e.g. function) to draw something useful.
Modularizing code with functions
• Functions can also be used to modularize big pieces of code into smaller pieces
• The smaller pieces can then be assembled or reused exactly like Lego pieces
Exercise: Copy or type-in the “Car” program
from the “Draw with code” booklet /
playground.
If you typed everything correctly you should see
the following drawing when running the
program.
Modularizing the code
function background()
{
// Background
noStroke();
fill(180, 199, 231);
rect(0, 0, 800, 500);
fill(191, 144, 0);
rect(0, 500, 800, 100);
}
function sun()
{
// Sun
fill("yellow");
circle(750, 50, 150);
stroke("yellow");
strokeWeight(6);
line(480, 60, 561, 47);
line(548, 224, 602, 172);
line(740, 304, 747, 236);
}
function car()
{
// Car
stroke("black");
strokeWeight(1);
fill(112, 173, 71);
rect(175, 340, 223, 54);
rect(108, 394, 362, 74);
fill(132,60,12);
circle(168, 468, 32);
circle(408, 468, 32);
}
background();
sun();
car();
This is main body of our new program. Of course, this program calls the
specified functions.
In big programs, functions can be moved outside the main program in
external module or libraries.
Defining loop() function
function background()
{
...
}
function sun()
{
...
}
function car()
{
...
}
function loop()
{
background();
sun();
car();
}
• loop() is a special
function.
• We don’t have to
call it.
• The system will call
it automatically
about 60 times /
second.
Parametrize car() function
car(108);
function car(x)
{
// Car
stroke("black");
strokeWeight(1);
fill(112, 173, 71);
rect(x + 67, 340, 223, 54);
rect(x, 394, 362, 74);
fill(132,60,12);
circle(x + 60, 468, 32);
circle(x + 300, 468, 32);
}
We’ll update function car() to
accept a parameter x
representing the x coordinate
where the car will be drawn.
x = 108 x = 400 x = 650
… …
function loop()
{
Step 1: Clear the frame
Step 2: Redraw the
scene and car at
position x
Step 3: Increase
position x by 1
}
Animations
Increasing / decreasing variables
x++;
x += 1;
x = x + 1;
x--;
x -= 1;
x = x - 1;
Increasing the value Decreasing the value
Note: x++ and x-- forms always modify the value by 1.
The other forms can be used to modify the value by an arbitrary amount.
OR
OR
OR
OR
let x = 0;
function loop()
{
clear();
background();
sun();
car(x);
x++;
}
function car(x)
{
// Car
stroke("black");
strokeWeight(1);
fill(112, 173, 71);
rect(x + 67, 340, 223, 54);
rect(x, 394, 362, 74);
fill(132,60,12);
circle(x + 60, 468, 32);
circle(x + 300, 468, 32);
}
function background()
{
// Background
noStroke();
fill(180, 199, 231);
rect(0, 0, 800, 500);
fill(191, 144, 0);
rect(0, 500, 800, 100);
}
function sun()
{
// Sun
fill("yellow");
circle(750, 50, 150);
stroke("yellow");
strokeWeight(6);
line(480, 60, 561, 47);
line(548, 224, 602, 172);
line(740, 304, 747, 236);
}
Program
listing
Next steps
• Complete the exercises presented today. Don’t
be frustrated if you’ll encounter errors. Coding
required lots of practice until you get
comfortable writing programs.
• When working on a program, try to run the
program from time to time to avoid
accumulation of errors.
• Explore the other tutorials and projects from
the codeguppy.com website and don’t forget to
visit also the downloads section.
Algorithms More…
Games
Animations
https://codeguppy.com
Free coding platform
Ad

More Related Content

Similar to Introduction to Coding (20)

A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) Things
Michael Pirnat
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
tutorialsruby
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
tutorialsruby
 
The Ring programming language version 1.5.3 book - Part 57 of 184
The Ring programming language version 1.5.3 book - Part 57 of 184The Ring programming language version 1.5.3 book - Part 57 of 184
The Ring programming language version 1.5.3 book - Part 57 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 47 of 184
The Ring programming language version 1.5.3 book - Part 47 of 184The Ring programming language version 1.5.3 book - Part 47 of 184
The Ring programming language version 1.5.3 book - Part 47 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 58 of 210
The Ring programming language version 1.9 book - Part 58 of 210The Ring programming language version 1.9 book - Part 58 of 210
The Ring programming language version 1.9 book - Part 58 of 210
Mahmoud Samir Fayed
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
amitsarda3
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video game
dandylion13
 
ma project
ma projectma project
ma project
Aisu
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
shafiq sangi
 
Ch3
Ch3Ch3
Ch3
Uğurcan Uzer
 
Circles graphic
Circles graphicCircles graphic
Circles graphic
alldesign
 
Displaying information within a window.68
Displaying information within a window.68Displaying information within a window.68
Displaying information within a window.68
myrajendra
 
Arduino coding class part ii
Arduino coding class part iiArduino coding class part ii
Arduino coding class part ii
Jonah Marrs
 
Creating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfCreating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdf
ShaiAlmog1
 
The Ring programming language version 1.7 book - Part 50 of 196
The Ring programming language version 1.7 book - Part 50 of 196The Ring programming language version 1.7 book - Part 50 of 196
The Ring programming language version 1.7 book - Part 50 of 196
Mahmoud Samir Fayed
 
Unreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorUnreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal Editor
Nick Pruehs
 
Ember.js Tokyo event 2014/09/22 (English)
Ember.js Tokyo event 2014/09/22 (English)Ember.js Tokyo event 2014/09/22 (English)
Ember.js Tokyo event 2014/09/22 (English)
Yuki Shimada
 
The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202
Mahmoud Samir Fayed
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) Things
Michael Pirnat
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
tutorialsruby
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
tutorialsruby
 
The Ring programming language version 1.5.3 book - Part 57 of 184
The Ring programming language version 1.5.3 book - Part 57 of 184The Ring programming language version 1.5.3 book - Part 57 of 184
The Ring programming language version 1.5.3 book - Part 57 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 47 of 184
The Ring programming language version 1.5.3 book - Part 47 of 184The Ring programming language version 1.5.3 book - Part 47 of 184
The Ring programming language version 1.5.3 book - Part 47 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 58 of 210
The Ring programming language version 1.9 book - Part 58 of 210The Ring programming language version 1.9 book - Part 58 of 210
The Ring programming language version 1.9 book - Part 58 of 210
Mahmoud Samir Fayed
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
amitsarda3
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video game
dandylion13
 
ma project
ma projectma project
ma project
Aisu
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
shafiq sangi
 
Circles graphic
Circles graphicCircles graphic
Circles graphic
alldesign
 
Displaying information within a window.68
Displaying information within a window.68Displaying information within a window.68
Displaying information within a window.68
myrajendra
 
Arduino coding class part ii
Arduino coding class part iiArduino coding class part ii
Arduino coding class part ii
Jonah Marrs
 
Creating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfCreating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdf
ShaiAlmog1
 
The Ring programming language version 1.7 book - Part 50 of 196
The Ring programming language version 1.7 book - Part 50 of 196The Ring programming language version 1.7 book - Part 50 of 196
The Ring programming language version 1.7 book - Part 50 of 196
Mahmoud Samir Fayed
 
Unreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorUnreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal Editor
Nick Pruehs
 
Ember.js Tokyo event 2014/09/22 (English)
Ember.js Tokyo event 2014/09/22 (English)Ember.js Tokyo event 2014/09/22 (English)
Ember.js Tokyo event 2014/09/22 (English)
Yuki Shimada
 
The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202
Mahmoud Samir Fayed
 

More from Fabio506452 (12)

Lo_real_y_lo_virtual_-_Tomas_Maldonado.pdf
Lo_real_y_lo_virtual_-_Tomas_Maldonado.pdfLo_real_y_lo_virtual_-_Tomas_Maldonado.pdf
Lo_real_y_lo_virtual_-_Tomas_Maldonado.pdf
Fabio506452
 
Defensa Garello
Defensa GarelloDefensa Garello
Defensa Garello
Fabio506452
 
Infografia Cambio de hábitos
Infografia Cambio de hábitosInfografia Cambio de hábitos
Infografia Cambio de hábitos
Fabio506452
 
Robotica 2 Actividad 1.pdf
Robotica 2 Actividad  1.pdfRobotica 2 Actividad  1.pdf
Robotica 2 Actividad 1.pdf
Fabio506452
 
Alfabetización Academica
Alfabetización AcademicaAlfabetización Academica
Alfabetización Academica
Fabio506452
 
Tutorial - Cómo ingresar al aula
Tutorial - Cómo ingresar al aulaTutorial - Cómo ingresar al aula
Tutorial - Cómo ingresar al aula
Fabio506452
 
Entre lo sólido y lo espectral
Entre lo sólido y lo espectralEntre lo sólido y lo espectral
Entre lo sólido y lo espectral
Fabio506452
 
Cajas Navideñas
Cajas NavideñasCajas Navideñas
Cajas Navideñas
Fabio506452
 
Santa Fe Hace un siglo
Santa Fe Hace un sigloSanta Fe Hace un siglo
Santa Fe Hace un siglo
Fabio506452
 
Avalos-Katherine-Investigacion.pdf
Avalos-Katherine-Investigacion.pdfAvalos-Katherine-Investigacion.pdf
Avalos-Katherine-Investigacion.pdf
Fabio506452
 
CreditosHipotecarios.pdf
CreditosHipotecarios.pdfCreditosHipotecarios.pdf
CreditosHipotecarios.pdf
Fabio506452
 
Archivo fotografico FC Santa Fe
Archivo fotografico FC Santa FeArchivo fotografico FC Santa Fe
Archivo fotografico FC Santa Fe
Fabio506452
 
Lo_real_y_lo_virtual_-_Tomas_Maldonado.pdf
Lo_real_y_lo_virtual_-_Tomas_Maldonado.pdfLo_real_y_lo_virtual_-_Tomas_Maldonado.pdf
Lo_real_y_lo_virtual_-_Tomas_Maldonado.pdf
Fabio506452
 
Infografia Cambio de hábitos
Infografia Cambio de hábitosInfografia Cambio de hábitos
Infografia Cambio de hábitos
Fabio506452
 
Robotica 2 Actividad 1.pdf
Robotica 2 Actividad  1.pdfRobotica 2 Actividad  1.pdf
Robotica 2 Actividad 1.pdf
Fabio506452
 
Alfabetización Academica
Alfabetización AcademicaAlfabetización Academica
Alfabetización Academica
Fabio506452
 
Tutorial - Cómo ingresar al aula
Tutorial - Cómo ingresar al aulaTutorial - Cómo ingresar al aula
Tutorial - Cómo ingresar al aula
Fabio506452
 
Entre lo sólido y lo espectral
Entre lo sólido y lo espectralEntre lo sólido y lo espectral
Entre lo sólido y lo espectral
Fabio506452
 
Cajas Navideñas
Cajas NavideñasCajas Navideñas
Cajas Navideñas
Fabio506452
 
Santa Fe Hace un siglo
Santa Fe Hace un sigloSanta Fe Hace un siglo
Santa Fe Hace un siglo
Fabio506452
 
Avalos-Katherine-Investigacion.pdf
Avalos-Katherine-Investigacion.pdfAvalos-Katherine-Investigacion.pdf
Avalos-Katherine-Investigacion.pdf
Fabio506452
 
CreditosHipotecarios.pdf
CreditosHipotecarios.pdfCreditosHipotecarios.pdf
CreditosHipotecarios.pdf
Fabio506452
 
Archivo fotografico FC Santa Fe
Archivo fotografico FC Santa FeArchivo fotografico FC Santa Fe
Archivo fotografico FC Santa Fe
Fabio506452
 
Ad

Recently uploaded (20)

Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Ad

Introduction to Coding

  • 2. Part I: Introduction • About codeguppy.com • Creating accounts in codeguppy.com • Environment overview Part II: Steps into coding • Drag and drop coding • Drawing with code • Animations Agenda
  • 3. codeguppy.com About codeguppy.com • Online coding platform for kids, teens and code newbies • Text-based coding • JavaScript language • Based on p5.js (Processing API) • Code animations, games and other fun programs • Built-in assets (backgrounds, sprites, etc.) • Tons of projects. Browse – Remix – Share • Free!
  • 4. Why learn JavaScript? • JavaScript is a super-popular real-world programming language used both by beginners but also by professional software developers. (The entire codeguppy.com was coded in JavaScript) • People use JavaScript to build websites, online games and do creative coding. On codeguppy.com, you can use JavaScript to draw with code, implement animations, build games and other fun projects. • Coding in a text-based language such as JavaScript has also other benefits beyond the world of programming. It enhances problem- solving skills but also attention to details.
  • 5. Programming is like writing a book... … except if you miss out a single comma on page 349 the whole thing you wrote makes no sense. - Anonymous
  • 6. codeguppy.com Let’s open an account with codeguppy.com • codeguppy.com gives you unlimited space in the cloud to write and store tons of programs • But first you need to open an account with codeguppy.com • You need to provide a valid email address and a password (website doesn’t ask any other personal details) Note: After registration, you should get an email from codeguppy.com. Please verify your email by clicking the link in the email. JOIN FOR FREE Email: Password: REGISTER NOW Register with email 1 2 3
  • 7. Code Editor Type here your program Assets Toolbar Browse sprite library, colors, etc. Run / Stop Button Run or Stop your program. Output Canvas Here you’ll see the output of your program.
  • 9. Let’s play with built-in assets sprite('adventure_girl.idle', 400, 300, 0.5); sprite('knight.idle', 400, 300, 0.5); You don’t have to write the above code. Just drag and drop a sprite from the palette in the code editor to have this code generated for you.
  • 10. music('Fun Background'); background('Field'); sprite('plane.fly', 400, 300, 0.5); Build a program using drag-and-drop Step 1: Drag and drop a music file Step 2: Drag and drop a background image or color Step 3: Drag and drop a sprite Press “Play” when ready.
  • 11. Built-in instruction that asks computer to display a sprite on the canvas. The actual sprite is specified in between quotes inside the parenthesis as a “parameter”. Parameters of the instruction. Parameters specify what sprite to display, where to display it on the canvas and at what coordinates. Experiment: Try to change the 400 and 300 numbers with other numbers between 0 and 800. Press “Play” / “Stop” after each modification to run / stop the program. sprite('adventure_girl.idle', 400, 300, 0.5);
  • 12. • Programs can write and draw on a graphical canvas of 800x600 pixels • Origin is in the top-left corner • Middle of the canvas is at about (400, 300) • x coordinate goes from 0 to 800 (left to right) • y coordinate goes from 0 to 600 (top to bottom) (400, 300) Output canvas
  • 13. Our first type-in program circle(400, 300, 300); • Type carefully this line in the code editor. • Make sure you use the same casing as illustrated and include all the punctuation signs. • When ready, press the Play / Run button
  • 14. circle(400, 300, 300); Built-in instruction that asks computer to draw a circle on the canvas. codeguppy.com has many built- in instructions for different purposes (remember the sprite instruction used before). Parameters of the instruction. There are 3 parameters inside parenthesis and separated by comma: - 400, 300 - coordinates of circle center - 300 – radius of the circle Try to modify the parameters of this instruction and notice the effect. Don’t forget to press “Play” / “Stop” after each modification.
  • 15. codeguppy.com/code.html // Draw bear face circle(400, 300, 200); // Draw left ear circle(250, 100, 50); circle(270, 122, 20); // Draw right ear circle(550, 100, 50); circle(530, 122, 20); // Draw left eye circle(300, 220, 30); circle(315, 230, 10); // Draw right eye circle(500, 220, 30); circle(485, 230, 10); // Draw nose circle(400, 400, 90); circle(400, 350, 20); Multiple instructions in a program
  • 16. Other graphical instructions circle(400, 300, 200); ellipse(400, 300, 300, 200); rect(400, 300, 300, 200); line(400, 300, 500, 500); triangle(400, 100, 200, 400, 600, 500); arc(400, 300, 300, 200, 0, 180); point(400, 300); text('JavaScript', 400, 300); JavaScript (400, 300) 200 (400, 300) 300 200 (400, 300) 300 200 (400, 300) (500, 500) (200, 400) (600, 500) (400, 100) (400, 300) (400, 300) (400, 300)
  • 17. Practicing graphical instructions • Exercise 1: On a blank piece of paper draw an object / scene using only basic shapes such as circles, lines, rectangles. Convert that drawing into code! OR • Exercise 2: Download the “Draw with code” booklet from the downloads section. Choose any drawing, print the page and type-in the program. Note: Programs from the “Draw with code” booklet may have more instructions then presented here. Try to discover their purpose.
  • 18. Introducing variables let r = 100; let r2 = 100 - 4; circle(100, 100, r); circle(100, 100, r2); OR • JavaScript allows users to define variables to hold various values or the result of complex calculations • You can name variables however you prefer… but don’t start them with number or weird symbols • Variables are super important in programming
  • 19. Expressions and variables instead of scalars circle(100, 100, 100); circle(100, 100, 96); You can let the computer do calculations. At the end of the day, your computer is also a powerful calculator. circle(100, 100, 100); circle(100, 100, 100 - 4); let r2 = 100 – 4; circle(100, 100, 100); circle(100, 100, r2);
  • 20. Building our own custom instructions circle2(); function circle2() { circle(100, 100, 100); circle(100, 100, 100 - 4); } • We placed the two circle instructions inside a code block (delimited by curly brackets) • The block is the body of function circle2. Notice carefully the syntax. • The function circle2 is our new custom instructions. However, exactly like circle, it doesn’t do anything until we call it. 1 2 3 1 2 3
  • 21. Functions with parameters circle2(400, 300, 100); function circle2(x, y, r) { circle(x, y, r); circle(x, y, r - 4); } Now this is a useful function! It can be used to draw a double-circle on the canvas. We can control the position and radius of the double circle! Exercise: Design your own custom instruction (e.g. function) to draw something useful.
  • 22. Modularizing code with functions • Functions can also be used to modularize big pieces of code into smaller pieces • The smaller pieces can then be assembled or reused exactly like Lego pieces Exercise: Copy or type-in the “Car” program from the “Draw with code” booklet / playground. If you typed everything correctly you should see the following drawing when running the program.
  • 23. Modularizing the code function background() { // Background noStroke(); fill(180, 199, 231); rect(0, 0, 800, 500); fill(191, 144, 0); rect(0, 500, 800, 100); } function sun() { // Sun fill("yellow"); circle(750, 50, 150); stroke("yellow"); strokeWeight(6); line(480, 60, 561, 47); line(548, 224, 602, 172); line(740, 304, 747, 236); } function car() { // Car stroke("black"); strokeWeight(1); fill(112, 173, 71); rect(175, 340, 223, 54); rect(108, 394, 362, 74); fill(132,60,12); circle(168, 468, 32); circle(408, 468, 32); } background(); sun(); car(); This is main body of our new program. Of course, this program calls the specified functions. In big programs, functions can be moved outside the main program in external module or libraries.
  • 24. Defining loop() function function background() { ... } function sun() { ... } function car() { ... } function loop() { background(); sun(); car(); } • loop() is a special function. • We don’t have to call it. • The system will call it automatically about 60 times / second.
  • 25. Parametrize car() function car(108); function car(x) { // Car stroke("black"); strokeWeight(1); fill(112, 173, 71); rect(x + 67, 340, 223, 54); rect(x, 394, 362, 74); fill(132,60,12); circle(x + 60, 468, 32); circle(x + 300, 468, 32); } We’ll update function car() to accept a parameter x representing the x coordinate where the car will be drawn.
  • 26. x = 108 x = 400 x = 650 … … function loop() { Step 1: Clear the frame Step 2: Redraw the scene and car at position x Step 3: Increase position x by 1 } Animations
  • 27. Increasing / decreasing variables x++; x += 1; x = x + 1; x--; x -= 1; x = x - 1; Increasing the value Decreasing the value Note: x++ and x-- forms always modify the value by 1. The other forms can be used to modify the value by an arbitrary amount. OR OR OR OR
  • 28. let x = 0; function loop() { clear(); background(); sun(); car(x); x++; } function car(x) { // Car stroke("black"); strokeWeight(1); fill(112, 173, 71); rect(x + 67, 340, 223, 54); rect(x, 394, 362, 74); fill(132,60,12); circle(x + 60, 468, 32); circle(x + 300, 468, 32); } function background() { // Background noStroke(); fill(180, 199, 231); rect(0, 0, 800, 500); fill(191, 144, 0); rect(0, 500, 800, 100); } function sun() { // Sun fill("yellow"); circle(750, 50, 150); stroke("yellow"); strokeWeight(6); line(480, 60, 561, 47); line(548, 224, 602, 172); line(740, 304, 747, 236); } Program listing
  • 29. Next steps • Complete the exercises presented today. Don’t be frustrated if you’ll encounter errors. Coding required lots of practice until you get comfortable writing programs. • When working on a program, try to run the program from time to time to avoid accumulation of errors. • Explore the other tutorials and projects from the codeguppy.com website and don’t forget to visit also the downloads section. Algorithms More… Games Animations