This page or section is in question as to whether it is useful or not. You can discuss whether you think it should be deleted or not on its talk page. (June 2018) Reason: Same as Pen Projects |
It has been suggested that this page's contents be merged with the page Pen Projects. You can discuss this on the page's talk page. (September 2022) |
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.[1]
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) set pen shade to (s2) pen down go to x:(x2)y:(y2) pen up define Make circle at (x)(y) color (c) shade (s) radius (r) pen up // this block will draw a circle go to x:(x)y:(y) set pen color to (c) set pen size to (r) set pen shade to (s) pen down pen up when green flag clicked set [level v] to [1] // 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 [0] // 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?) = [1]> then set [jump power v] to [12] // 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 [1] // this block detects where the player is and what they are touching else set [can jump? v] to [0] 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.[2]
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 shade to (s2) // shade 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) = [1]> then // fill Draw Square at (x) (y) color (c) size ((s) - (6)) shade (s2) Size of pen (s3) filled? (0) :: custom end if <(costume #) = [3]> 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 shade to (s2) 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 [0] // resetting the player's position set [player Y v] to [0] // 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) > [226]> then // Stopping the player from going off screen set [player X v] to [226] end if <(player X) < [-226]> then // Stopping the player from going off screen set [player X v] to [-226] end if <(player Y) > [166]> then // Stopping the player from going off screen set [player Y v] to [166] 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 #) = [4]> 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)) if <touching color [your bad color] ?> then broadcast [Game over v] end go to x: ((player X) + (12)) y: ((player Y) - (12)) if <touching color [your bad color] ?> then broadcast [Game over v] end go to x: ((player X) - (12)) y: ((player Y) - (12)) if <touching color [your bad color] ?> then broadcast [Game over v] end go to x: ((player X) - (12)) y: ((player Y) + (12)) if <touching color [your bad color] ?> then broadcast [Game over v] 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)) = [1]> then // this system moves the clone to a random edge if <(y position) > [0]> 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) > [0]> 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) = [90]> then // this deletes the clone if it is at its destination if <(x position) = [240]> 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) = [0]> then // this deletes the clone if it is at its destination if <(y position) = [180]> then delete this clone end end if <(direction) = [180]> 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 #) = [3]> 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.