Making Snake Game for Linux using My Own Language

  Рет қаралды 32,591

Tsoding Daily

Tsoding Daily

Күн бұрын

Пікірлер: 60
@smooll_d
@smooll_d 3 жыл бұрын
"I've implemented a lot of small games in the past but never actually Snake, which is quite poggers."
@bassguitarbill
@bassguitarbill 3 жыл бұрын
Really really good episode, it's very fun to see this language evolve over time.
@burnax9817
@burnax9817 3 жыл бұрын
he made an entire fucking programming language to make snake game, am impressed
@remrevo3944
@remrevo3944 2 жыл бұрын
1:11:06 In rust there is something called a never type, which signals that no point after it will ever be reached. (It's used for example in case of infinite loops, or also for the exit syscall. I think something like that might be possible to use for porth too.
@davidkatz1017
@davidkatz1017 3 жыл бұрын
For let bindings where you want some of them to be returned to the stack automatically, you could use the same syntax as in `proc`. Like: ``` 1 2 3 4 let a b c d -- a b in a print b print c print d print end print print // 123421 ```
@denoww9261
@denoww9261 3 жыл бұрын
I like this idea
@koktszfung
@koktszfung 3 жыл бұрын
And you can do let a b c d -- b a in 😱
@chivvii
@chivvii 3 жыл бұрын
and maybe you do this: let a b c d -- in ... end as a shorthand for leave all the bindings on the stack.
@minamagdy4126
@minamagdy4126 3 жыл бұрын
For readability, no. Th a should be how to remove all elements from the stack. I suggest this for let all stay: let a b c in # # end Basically have the default be peek, and bikeshedder operator denote dump all and leave this in the stack.
@minamagdy4126
@minamagdy4126 3 жыл бұрын
Better yet: have syntax like th I work as suggested here for custom stack manipulation: let a b c -- b c a end This is an example of rewriting rot in terms of my modification of let bindings.
@whythosenames
@whythosenames 3 жыл бұрын
you could use take as a divider between what you want to peek and take, so at 21:10 you would have let y x take px py in ... end if you just want to peek it would be let a b in ... end and if you want to take it would be let take a b in ... end
@kaksisve4012
@kaksisve4012 3 жыл бұрын
That formula can be suitable for alignment. It tries to align `s` bytes at boundary `w`, or at smaller boundaries. a(w, s) = when s % w == 0 -> s s > w -> s + w - s % w s < w -> a(w / 2, s)
@foxoninetails_
@foxoninetails_ 3 жыл бұрын
You don't actually need signed mod to handle wrapping! The following would wrap your coordinates properly without ever touching negative numbers, as long as your board isn't hypermassive. let x y in x COLS + COLS % y ROWS + ROWS % end The reason this works is that mod is essentially a wrapping operation in and of itself; if the dividend is greater than the divisor, it wraps the dividend so that it's in range. By adding the divisor to the dividend before doing mod, you offset the operation so that you never have to deal with negatives, without changing the result. This method does limit your board size to half of the maximum integer, but that's an excessively impractical size anyway.
@emilioschmidt2106
@emilioschmidt2106 3 жыл бұрын
1:15:25 I've always wondered *why* moding produces negatives (in C) Why does (-4)%3 equal -1 and not 2, like in python. What is the advantage of that?
@hanqnero
@hanqnero 2 жыл бұрын
As I know Python's mod operation is mathematicaly correct while in many other languages they just slap minus to the result if there are negative operands, because historicaly in Intel CPUs the modulo operation was implemented that way.
@SaHaRaSquad
@SaHaRaSquad 2 жыл бұрын
These are two different operations: modulo and remainder. Remainder produces negative numbers if the result of the division is negative (for example -10/4). The function of the % operator is not consistent between languages. Some languages have both variants, usually named "mod" and "rem" or something along those lines.
@dwightk.schrute8696
@dwightk.schrute8696 3 жыл бұрын
59:50 JavaScript programmers have destructuring and spread operators mr. zozing
@rogo7330
@rogo7330 3 жыл бұрын
58:55 - when I was writing a selfcorrected clock bar I experimented with usleep at first (and it was an awful laggy garbage), then I tried with nanosleep. When I passed one minute to the tv_nsec (1 second * 60) my laptop almost melted down and shit around. Don't know why is that. When I passed one minute to tv_sec all was right.
@mbarrio
@mbarrio 3 жыл бұрын
I learn so much by your mistakes, analysis and explanation. Thanks.
@Pi7on
@Pi7on 3 жыл бұрын
I really like the peek and take idea
@keldwikchaldain9545
@keldwikchaldain9545 2 жыл бұрын
I think I would've made the board a bit different: make every cell an int, have a length stored, every tick store the length in the player's current cell, decrement all the cells, and then print. Every cell that's >0 is part of the snake. If you eat an apple in a given tick, just don't decrement the cells.
@haxidenti6001
@haxidenti6001 2 жыл бұрын
Would be fun to write lua interpreter in porth :)
@civilizedgangster8024
@civilizedgangster8024 3 жыл бұрын
This felt like a fever dream
@ludfde
@ludfde 3 жыл бұрын
128 bit division for the win. :P
@niikurasu2855
@niikurasu2855 3 жыл бұрын
Thank you for uploading the streams :)
@ludoviclagouardette7020
@ludoviclagouardette7020 2 жыл бұрын
May the porth be with you
@stomah9832
@stomah9832 3 жыл бұрын
print the character twice for squareish pixels
@tusharmaurya1668
@tusharmaurya1668 3 жыл бұрын
32:03 that was funny 🤣🤣
@satsuki-rin
@satsuki-rin 3 жыл бұрын
it would be cool to have a variant of the let binding that automatically does the @ operation on whatever data beforehand and does the ! operation afterwords as i could see that being something someone would want to do commonly
@qwerty123443wifi
@qwerty123443wifi 3 жыл бұрын
Why not use git LFS for the assemblies?
@bigmistqke
@bigmistqke 3 жыл бұрын
I m organizing an exhibition w my friends and we r gonna call it 'the bikeshed will be red'
@kedusyared6589
@kedusyared6589 3 жыл бұрын
wait idk how to implement this. Let me check the docs. Oh wait I created this language. 😭
@astroblade3782
@astroblade3782 3 жыл бұрын
Hello! Im the person who failed to explain COQ; sorry about that. Nice job on the snake!
@0xjoemama
@0xjoemama 3 жыл бұрын
What if let bindings captured using peek or take only if you specify it? For example `let peek x peek y px py in ...`?
@kaksisve4012
@kaksisve4012 3 жыл бұрын
Then syntax will be too noisy.
@emilioschmidt2106
@emilioschmidt2106 3 жыл бұрын
Is there a way to represent fractional numbers (like floats) in porth?
@peterhebden1557
@peterhebden1557 2 жыл бұрын
Not yet
@desertfish74
@desertfish74 3 жыл бұрын
Another fine zozing session.
@Andrath
@Andrath 3 жыл бұрын
Porth needs ncurses bindings (just kidding! *runs away*)
@centralintelligenceagency6825
@centralintelligenceagency6825 3 жыл бұрын
Thank you Zozing.
@haiirokoneko6357
@haiirokoneko6357 2 жыл бұрын
Are you using emacs?
@MegaMrUnbelievable
@MegaMrUnbelievable 2 жыл бұрын
Did you based your language on C or C++? It looks a little bit similar
@devhypercoder2522
@devhypercoder2522 2 жыл бұрын
If you read the description of the language, it's like the stack based programming language forth Initially made in python, now is self hosted (written in itself)
@levoca-9296
@levoca-9296 2 жыл бұрын
I find it very different than C++ or C syntax and in the way that it works
@NeonLightRays
@NeonLightRays 2 жыл бұрын
its directly inspired by forth
@MegaMrUnbelievable
@MegaMrUnbelievable 2 жыл бұрын
@@NeonLightRays Thanks!
@rogo7330
@rogo7330 3 жыл бұрын
Keep bootstrap folder in a torrent :D
@smooll_d
@smooll_d 3 жыл бұрын
Why is it called reverse Polish notation? Can it kurwa? can it Grzegorz Brzęczyszczykiewicz? What's going on?
@smooll_d
@smooll_d 3 жыл бұрын
@Mekelaina oh so it's literally Polish. That's so fucking cool!
@frechjo
@frechjo 3 жыл бұрын
It can sing Gdzie jest biały węgorz backwards.
@emilioschmidt2106
@emilioschmidt2106 3 жыл бұрын
Who's Joe?
@spacewad8745
@spacewad8745 Жыл бұрын
joe mama
@Khusyasy
@Khusyasy 3 жыл бұрын
hello hello hello
@desertfish74
@desertfish74 3 жыл бұрын
How about that.
@Bobbias
@Bobbias 3 жыл бұрын
Dammit, you got your p all over the stack!
@thelambdafunction
@thelambdafunction 3 жыл бұрын
At this point, this is so much not Forth, that calling it Porth is quite.... Egh
@leastexpected3115
@leastexpected3115 3 жыл бұрын
Big flex
How Coroutines work on Assembly Level
2:09:30
Tsoding Daily
Рет қаралды 1,5 М.
Why Include Files Only Once?
1:49:53
Tsoding Daily
Рет қаралды 14 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Making My Own Programming Language and Coding a Game in It
10:19
AstroSam
Рет қаралды 1,3 МЛН
C++ Super Optimization: 1000X Faster
15:33
Dave's Garage
Рет қаралды 332 М.
The Magic of RISC-V Vector Processing
16:56
LaurieWired
Рет қаралды 348 М.
Retro MS-DOS Coding - Recreating the Iconic Award BIOS Screen
18:16
NCOT Technology
Рет қаралды 92 М.
So I made a Web Server using My Programming Language
1:49:05
Tsoding Daily
Рет қаралды 63 М.
If Jerma was Programmer
6:44
Tsoding Out Of Context
Рет қаралды 7 М.
The BEST Mechanical Display You've EVER Seen!!!
13:51
Tin Foil Hat
Рет қаралды 523 М.
Making Minimalist Snake Game in C on Linux
8:01
Nir Lichtman
Рет қаралды 34 М.
I Made My Own Programming Language
10:20
CodeNoodles
Рет қаралды 102 М.
the TRUTH about this NEW Language (BETTER Than Rust and C++?)
7:37