https://kotlinlang.org logo
#random
Title
# random
e

Eugen Martynov

02/11/2023, 7:33 PM
Does anyone have something to teach Kotlin as first programming language to child?
o

orangy

02/12/2023, 6:56 AM
With my own kids we were developing text adventure game. No UI, no complexity, just println and readln. We started with simple game loop with global variables for gold and hp in a single main function. I introduced randoms, ifs and whens, and then we went all the way to functions for decomposition, classes, etc etc. In the end it was pretty decent text adventure game with a lot of fun (and toilet jokes, kids!) 😄
e

Eugen Martynov

02/12/2023, 11:29 AM
Thanks
o

orangy

02/12/2023, 12:13 PM
One nice thing about such approach is that kid can lead the game design (“Daddy, I want to add gold chests to dig!“) and expose their creativity through the program, and adult can help find a way of how to achieve it using what is already learned. It is very important to not rush into “proper way of doing things” too early, hack the things together as simple as possible. And introduce new stuff very gradually, and so that value of new stuff is very clear.
e

Eugen Martynov

02/12/2023, 1:58 PM
Do you have it open source?
o

orangy

02/12/2023, 2:07 PM
No, sorry… That’s kids, it’s kinda sensitive 🙂
e

Eugen Martynov

02/12/2023, 2:09 PM
No issues! I will Google text adventure games first and think further. Thank you!
o

orangy

02/12/2023, 2:16 PM
You will sure find a lot of complex stuff, like various MUDs 🙂 Keep it simple. The game loop is like this: 1. generate random description of the surroundings, like
"$distance km: You are in the dark forest"
2. present options, initially just “go forward”, in the form of menu, like
1. Go forward 0. Exit game
3.
readln
input and process it 4. execute selected action (for “go forward” it’s just
distance++
) 5. go to #1 That’s it for a start! Then, introduce random and if, two major building blocks for a start. Replace surroundings with “You are in ${place}“, where
place
is something like
Copy code
val place : String
val number = random(3)
if (number == 0) place = "the dark forest" else if (number == 1) place = "the smelly swamp" else place = "the shitty toilet"
Work with your and kid’s imagination to add more and more 🙂
e

Eugen Martynov

02/12/2023, 2:22 PM
Funny, thank you for the idea
a

andylamax

02/13/2023, 11:46 AM
So good of an idea. I like it
y

Youssef Shoaib [MOD]

02/19/2023, 4:58 PM
This isn't kotlin but I initially learnt programming using CodeCombat. Sadly a lot of its content is now premium, but its approach was to gamify coding by having you control a character that has to do certain things, and it would reward you with a currency for things like having no code warnings or doing extra missions in a level etc.
8 Views