“Thonk Snake” by RedstoneTim
https://openprocessing.org/sketch/926565
License CreativeCommons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
WASD or arrow keys to move the thonk
CC Attribution ShareAlike
Thonk Snake
xxxxxxxxxx
float tile = 32;
float x = tile * 2, y = tile * 2;
float itemX, itemY;
char pressed = ' ';
int score = 0;
String[] avatarLinks = {
// Normal thinking (4)
"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/twitter/248/thinking-face_1f914.png", // Standard thinking
"https://emoji.gg/assets/emoji/7304_upsidedown_thinking.png", // Upside down thinking
"https://emoji.gg/assets/emoji/3952_molocle_think.png", // Monocle thinking
"https://emoji.gg/assets/emoji/4033_SuperiorThink.png", // Superior thinking
// Thonk (9)
"https://emoji.gg/assets/emoji/3305_thonkang.png", // Thonkang
"https://emoji.gg/assets/emoji/4209_thonkery.png", // Thonkery
"https://emoji.gg/assets/emoji/9798_thoonk.png", // Thoonk
"https://emoji.gg/assets/emoji/9295_thonk2.png", // Dumb thonk
"https://emoji.gg/assets/emoji/thonk.png", // Thonk
"https://emoji.gg/assets/emoji/Thonkery.png", // Thonkery
"https://emoji.gg/assets/emoji/7015_wide_thonk.png", // Wide thonk
"https://emoji.gg/assets/emoji/7587_hmm.png", // Pixel thonk
"https://emoji.gg/assets/emoji/5045_mlgthonk.png", // MLG thonk
// Food (12)
"https://emoji.gg/assets/emoji/4950_LemonThonk.png", // Lemon think
"https://emoji.gg/assets/emoji/6961_ThinkMelon.png", // Melon think
"https://emoji.gg/assets/emoji/6095_peach_think.png", // Peach think
"https://emoji.gg/assets/emoji/7128_thinktomato.png", // Tomato think
"https://emoji.gg/assets/emoji/4106_onionthink.png", // Onion think
"https://emoji.gg/assets/emoji/5025_PumpkinThink.png", // Pumpkin think
"https://emoji.gg/assets/emoji/2901_bean_thinking.png", // Bean think
"https://emoji.gg/assets/emoji/5058_think_shaker.png", // Shaker think
"https://emoji.gg/assets/emoji/3135_thinkpepper.png", // Pepper think
"https://emoji.gg/assets/emoji/ThinkingCheese.png", // Cheese think
"https://emoji.gg/assets/emoji/ThinkingLoaf.png", // Loaf think
"https://emoji.gg/assets/emoji/4867_MmM.png", // Cookie think
// Animals (5)
"https://emoji.gg/assets/emoji/7696_Thoink.png", // Thoink
"https://emoji.gg/assets/emoji/5914_tHONK.png", // Goose think
"https://emoji.gg/assets/emoji/7353_thonksgiving.png", // Turkey think
"https://emoji.gg/assets/emoji/2358_thinkgator.png", // Alligator think
"https://emoji.gg/assets/emoji/9279_axothonk.png", // Axolotl think
// Characters (19)
"https://emoji.gg/assets/emoji/8679_thinking_clown.png", // Clown think
"https://emoji.gg/assets/emoji/2147_AlienThinking.png", // Alien think
"https://emoji.gg/assets/emoji/9768_scoutthinking.png", // Scout think
"https://emoji.gg/assets/emoji/mariothink.png", // Mario think
"https://emoji.gg/assets/emoji/6863_thonk_luigi.png", // Luigi think
"https://emoji.gg/assets/emoji/thinksteve.png", // Steve think
"https://emoji.gg/assets/emoji/6521_villagerthink.png", // Villager think
"https://emoji.gg/assets/emoji/3015_PikaThonk.png", // Pika think
"https://emoji.gg/assets/emoji/2672_flareonThinking.png", // Flareon think
"https://emoji.gg/assets/emoji/3502_kirb_thonk.png", // Kirby think
"https://emoji.gg/assets/emoji/9088_SonicThonk.png", // Sonic think
"https://emoji.gg/assets/emoji/7553_thinkpac.png", // Pacman think
"https://emoji.gg/assets/emoji/2075_Waythonk.png", // Waythonk
"https://emoji.gg/assets/emoji/9331_SherThonkHolmes.png", // SherThonkHolmes
"https://emoji.gg/assets/emoji/9917_kronk_thonk.png", // Kronk think
"https://emoji.gg/assets/emoji/ThinkingLego.png", // Lego think
"https://emoji.gg/assets/emoji/1925_JojoThonk.png", // Jojo think
"https://emoji.gg/assets/emoji/7847_ugandan_thonk.png", // Ugandan think
"https://emoji.gg/assets/emoji/9648_lenny_thonk.png", // Lenny think
// Objects (4)
"https://emoji.gg/assets/emoji/9000_square_think.png", // Square think
"https://emoji.gg/assets/emoji/4731_EarthThonk.png", // Earth think
"https://emoji.gg/assets/emoji/8662_stonk.png", // Star think
"https://emoji.gg/assets/emoji/4133_milkythonk.png", // Milkyway think
// Extreme (6)
"https://emoji.gg/assets/emoji/3449_thinking.png", // Thinking thonking
"https://emoji.gg/assets/emoji/5157_thonktosis.png", // Thonktosis
"https://emoji.gg/assets/emoji/8445_Thinkllipsis.png", // Thinkllipsis
"https://emoji.gg/assets/emoji/9156_BanThonking.png", // Ban thonk
"https://emoji.gg/assets/emoji/6883_hyperthonking.png", // Hyper thonk
"https://emoji.gg/assets/emoji/8638_Thonk.png" // Ultimate thonk
};
PImage[] avatars = new PImage[avatarLinks.length];
String[] itemLinks = {
"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/twitter/248/green-book_1f4d7.png", // green book
"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/twitter/248/blue-book_1f4d8.png", // blue book
"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/twitter/248/orange-book_1f4d9.png" // orange book
};
PImage[] items = new PImage[itemLinks.length];
int item;
void setup() {
size(640, 640);
frameRate(12);
textFont(createFont("monospace", 30, true), 30);
regenerateItem();
// load images
for(int i = 0; i < avatars.length; i++) {
avatars[i] = loadImage(avatarLinks[i]);
image(avatars[i], 0, 0, tile, tile);
}
for(int i = 0; i < items.length; i++) {
items[i] = loadImage(itemLinks[i]);
image(items[i], 0, 0, tile, tile);
}
}
void draw() {
// draw background
//for (int i = 0; i < width; i += tile) {
// for (int j = 0; j < height; j += tile) {
// fill(255);
// rect(i, j, tile, tile);
// }
//}
fill(255);
rect(0, 0, width - 1, height - 1);
// draw player
image(avatars[min(score, avatars.length - 1)], x, y, tile, tile);
// draw item
image(items[min(item, items.length - 1)], itemX, itemY, tile, tile);
// draw score
fill(0);
text("Wisdom: " + score, 0, 30);
// move snake
y -= pressed == 'W' ? tile : 0;
y += pressed == 'S' ? tile : 0;
x -= pressed == 'A' ? tile : 0;
x += pressed == 'D' ? tile : 0;
// kill player if they run against the wall
if (x < 0 || x > (width - tile) || y < 0 || y > (height - tile)) {
playerDied();
}
// when the player eats the item, regenerate it
if ((x == itemX) && (y == itemY)) {
regenerateItem();
score++;
}
}
void regenerateItem() {
// TODO: Spawn the item in harder positions when the score gets higher
itemX = int(random(width) / tile) * tile;
itemY = int(random(height) / tile) * tile;
item = int(random(items.length));
}
void playerDied() {
x = tile * 2;
y = tile * 2;
regenerateItem();
pressed = ' ';
score = 0;
}
void keyPressed() {
pressed = (key == 'w' || keyCode == UP) && pressed != 'S' ? 'W' : pressed;
pressed = (key == 'a' || keyCode == LEFT) && pressed != 'D' ? 'A' : pressed;
pressed = (key == 's' || keyCode == DOWN) && pressed != 'W' ? 'S' : pressed;
pressed = (key == 'd' || keyCode == RIGHT) && pressed != 'A' ? 'D' : pressed;
}
See More Shortcuts