 This page or section is in question as to whether it is useful or not. You can discuss whether you want it deleted or not on its talk page. (June 2018)Reason: Same as Pen Projects

A 100% pen game is a game where almost everything is drawn in pen. This means having no sprites moving as the player. While pen games can range from having nothing in the costume to a large black rectangle being the costume, a 100% pen game’s sprite should be hidden, blank or a very small dot.

## Code

The coding on a pen platformer is usually complicated, as it involves drawing everything, even the player. Some pen platformers use Touching Color () blocks to detect walls, ceilings, and floors. Some pen platformers store solid blocks, hazard blocks, and high-jump blocks in lists to avoid lag with touching color blocks. You can also make pen games that are not platformers. These games usually have no gravity.

### How to Code a Pen Platformer

First, you need to create five variables.

```(PlayerX) // This stores the player's left/right position
(PlayerY) // this does the same, but with up/down
(level) // this stores the level the player is on
(jump power) // this makes a realistic jumping motion
(can jump?) // this says if the player can jump or not
```

Second, you need to make the costume a single small dot in the middle of the picture.

For the coding: Note: Pen games use a lot of code, therefore this next section is very large.
```define Draw line from (x)(y) to (x2)(y2) color (c) size (s) shade (s2)
pen up // this block will draw a line
go to x:(x)y:(y)
set pen color to (c)
set pen size to (s)
pen down
go to x:(x2)y:(y2)
pen up

pen up // this block will draw a circle
go to x:(x)y:(y)
set pen color to (c)
set pen size to (r)
pen down
pen up

when green flag clicked
set [level v] to  // resets the level
set [playerX v] to [-220] // resets the player's position
set [playerY v] to [-100] // resets the player's position
set [can jump? v] to  // tells the program if the player can jump
forever // Does what it says! runs it to ∞ and beyond!
erase all // resets the screen
floor::custom
broadcast (level) // draws the level
Draw circle at (playerX)(playerY) color (120) shade (50) radius (15)::custom // draws the player
Keys::custom // left and right arrow keys are detected here
Detections::custom
end

when I receive [1 v] // Level 1!
floor::custom
Detections::custom

define floor
Draw line from (-240)(-180) to (240)(-180) color (115) size (50) shade (50)::custom // This draws the floor.  Include this in every level.

when I receive [2 v] // Level 2!
floor::custom // floor!
Draw line from (0)(-180) to (0)(-120) color (115) size (50) shade (50)::custom // draws a line in the middle of the screen
Detections::custom

when I receive [3 v] // Level 3, Featuring lava!
Draw line from (0)(-180) to (0)(-100) color (0) size (2) shade (50)::custom
// This color is defined as “bad color”
floor::custom // Now that this is under the lava, this means that the lava will be under the floor.
Detections::custom

define Keys
if <key [right arrow v] pressed> then
change [playerX v] by (3) // move right
end
if <key [left arrow v] pressed> then
change [playerX v] by (-3) // move left
end

when green flag clicked
forever
if <key [up arrow v] pressed> then // the up arrow key needs to be separate so then you can move and jump at the same time
if <(can jump?) = > then
set [jump power v] to  // jump power is set to 12
repeat (jump power) // = jump power
change [playerY v] by (jump power) // moves the player
change [jump power v] by (-1) // makes the motion happen
end
end
end
end

define Detections
go to x:(playerX)y:((playerY) + (-12)) // floor
if <touching color [Ground color goes here]?> then
set [can jump? v] to  // this block detects where the player is and what they are touching

else
set [can jump? v] to 
change [playerY v] by (-5)
end
go to x:((playerX) + (12))y:(playerY) // detecting a wall on the right
if <touching color [Wall color goes here]?> then
change [playerX v] by (-3)

end
go to x:((playerX) + (-12))y:(playerY) // detecting a wall on the left
if <touching color [Wall color goes here]?> then
change [playerX v] by (3)

end
go to x:(playerX)y:((playerY) + (-12)) // detecting if player is standing on a bad color
if <touching color [Bad color goes here]?> then
set [playerX v] to [-220]
set [playerY v] to [-100]

end
go to x:((playerX) + (12))y:(playerY) // detecting if a bad color is on the right
if <touching color [Bad color goes here]?> then
set [playerX v] to [-220]
set [playerY v] to [-100]

end
go to x:((playerX) + (-12))y:(playerY) // detecting if a bad color is on the left
if <touching color [Bad color goes here]?> then
set [playerX v] to [-220]
set [playerY v] to [-100]

end
go to x:(playerX)y:((playerY) + (12)) // detecting if a bad color is on top
if <touching color [Bad color goes here]?> then
set [playerX v] to [-220]
set [playerY v] to [-140]

end

when green flag clicked
forever
if <(playerX) > (235)> then
set [playerX v] to [-220]
set [playerY v] to [-140]
change [level v] by (1)
end

```

### Other Pen Games

Other than a usual platformer, these types of games can go from avoiding large objects to jumping off walls to avoiding things. All types of pen games usually involve a fair amount of coding. The code to make a game in which the goal of it is to avoid moving blocks with pen is shown below.

First, you need to make two variables.

```(Player X) // this stores the player's x position
(Player Y) // this store the player's y position
```

Second, change or add 2 costumes. They should look the same. The costumes should be a single dot in the middle of the costume editor.

```
define Draw Square at (x) (y) color (c) size (s) shade (s2) Size of pen (s3) filled? (F)
pen up // This custom block is a Run Without Screen Refresh block
go to x: ((x) + (s)) y: ((y) + (s)) // goes to the top left corner
set pen color to (c) // color
set pen size to (s3) // size
pen down
go to x: ((x) + (s)) y: ((y) - (s)) // bottom right
go to x: ((x) - (s)) y: ((y) - (s)) // bottom left
go to x: ((x) - (s)) y: ((y) + (s)) // top left
go to x: ((x) + (s)) y: ((y) + (s)) // top right
pen up
if <(F) = > then // fill
Draw Square at (x) (y) color (c) size ((s) - (6)) shade (s2) Size of pen (s3) filled? (0) :: custom
end
if <(costume #) = > then
go to x: (x) y: (y) // resets the clones so they don't fly off into the top left hand corner
end

define Draw line from (x) (y) to (x2) (y2) color (c) size (s) shade (s2) Draws lines
pen up
go to x: (x) y: (y)
set pen color to (c)
set pen size to (s)
pen down
go to x: (x2) y: (y2)
pen up

when green flag clicked
switch costume to [costume1 v] // Telling if you are a clone
set [player X v] to  // resetting the player's position
set [player Y v] to  // resetting the player's position
forever
erase all
Draw Square at (player X) (player Y) color (0) size (10) shade (50) Size of pen (8) filled? (1) :: custom // drawing the player
broadcast [Draw Clones v] and wait // drawing the flying squares
Keys :: custom // Detecting up/down/left/right
Detect :: custom // Are you touching the squares?
end

when green flag clicked
forever
create clone of [Sprite1 v] // creating clones for the other squares
wait (0.2) secs // waiting...
end

define Keys
if <key [up arrow v] pressed?> then // up
change [player Y v] by (5)
end
if <key [down arrow v] pressed?> then // down
change [player Y v] by (-5)
end
if <key [left arrow v] pressed?> then // left
change [player X v] by (-5)
end
if <key [right arrow v] pressed?> then  // right
change [player X v] by (5)
end
if <(player X) > > then // Stopping the player from going off screen
set [player X v] to 
end
if <(player X) < [-226]> then // Stopping the player from going off screen
set [player X v] to [-226]
end
if <(player Y) > > then // Stopping the player from going off screen
set [player Y v] to 
end
if <(player Y) < [-166]> then // Stopping the player from going off screen
set [player Y v] to [-166]
end

when I receive [Game over v] // Game over!
erase all // clearing the board
stop [all v] // stopping the game

define Detect
if <(costume #) = > then // This line determines if the sprite is a clone. The block as a whole detects if you are touching the squares. ‘Run without screen refresh’ should be on
go to x: ((player X) + (12)) y: ((player Y) + (12))
end
go to x: ((player X) + (12)) y: ((player Y) - (12))
end
go to x: ((player X) - (12)) y: ((player Y) - (12))
end
go to x: ((player X) - (12)) y: ((player Y) + (12))
end
end

when I receive [Draw Clones v]
draw :: custom // drawing the other squares

when I start as a clone
switch costume to [costume3 v]
go to [random position v]
if <(pick random (1) to (2)) = > then // this system moves the clone to a random edge
if <(y position) > > then
set y to (180)
point in direction (180 v)
else
set y to (180)
point in direction (0 v)
end
else
if <(x position) > > then
set x to (240)
point in direction (-90 v)
else
set x to (-240)
point in direction (90 v)
end
end
forever
move (2) steps
if <(direction) = > then // this deletes the clone if it is at its destination
if <(x position) = > then
delete this clone
end
end
if <(direction) = [-90]> then // this deletes the clone if it is at its destination
if <(x position) = [-240]> then
delete this clone
end
end
if <(direction) = > then // this deletes the clone if it is at its destination
if <(y position) = > then
delete this clone
end
end
if <(direction) = > then // this deletes the clone if it is at its destination
if <(y position) = [-180]> then
delete this clone
end
end
end

define draw
if <(costume #) = > then // ‘Run without screen refresh’ should be checked for this block
Draw Square at (x position) (y position) color (115) size (10) shade (50) Size of pen (8) filled? (1) :: custom // draws the other squares
stop [this script v]
end

```

You have now created a pen game.