Make 2048 In Python | Full Python Game Tutorial

  Рет қаралды 34,301

Tech With Tim

Tech With Tim

Күн бұрын

In this Python tutorial, I will be showing you how to build the game "2048". This childhood-favorite of mine is a bit complex so I will be showing you some advanced techniques to structure a game like this. By the end of this video, you will have a fully-functional game to add to your portfolio in addition to a handful of new techniques to add to your toolbelt.
🎓 Premium Courses 🎓
🏢 CourseCareers - techwithtim.net/dev
🎓 Free Courses 🎓
📚 Introduction To Software Development: techwithtim.net/dev
🎞 Video Resources 🎞
Full Code: github.com/techwithtim/2048-I...
Install Pygame (Mac): • How to Install Pygame ...
Install Pygame (Windows): • How to Install Pygame ...
⏳ Timestamps ⏳
00:00 | Project Demo
00:50 | Project Overview/Plan
02:18 | Setup/Dependencies
03:45 | Constants Definition
08:27 | Game Loop
11:54 | Drawing
19:42 | Defining The Tiles
39:54 | Moving The Tiles - Explanation
46:07 | Moving The Tiles - Implementation
🔖 Tags 🔖
- Python Game Development
- Building Games in Python
- How To Code A Game
Hashtags
#pythonprogramming
#techwithtim
#pythongame

Пікірлер: 43
@TechWithTim
@TechWithTim Ай бұрын
Interested in becoming a developer? Check out my premium software development program with CourseCareers -> techwithtim.net/dev
@aidannnt
@aidannnt Ай бұрын
you're the only person who still walks us through how to use pip 😅 keep it up!
@user-bd8xt6fh6n
@user-bd8xt6fh6n 26 күн бұрын
You are the only one person who teached me Socket programming correctly in 2021. 3 years passed
@Bubbazilla
@Bubbazilla Ай бұрын
This is just what I needed, Thank you Tim!!
@toolzshed
@toolzshed Ай бұрын
Whoa sweet 🤘🏽🔥
@user-ts9ks8in2n
@user-ts9ks8in2n Ай бұрын
Awesome Tim!
@TanmayBhatgare
@TanmayBhatgare Ай бұрын
Wtf bro you made better frontend in python than me in HTML😢
@jacobmars1902
@jacobmars1902 Ай бұрын
reality is often disappointing
@IlTjaylI
@IlTjaylI Ай бұрын
Reality is realising that you will forever be disappointed in yourself if you compare yourself to others. Many people don't get that that statement really means. It means the someone will always be better than you at something because they have more experience and sometimes an experience you will never truly match unless you put your heart to it.
@Mecagothits
@Mecagothits 24 күн бұрын
Hahah yeah trio
@abdulwajid923
@abdulwajid923 27 күн бұрын
Great video i learn a lot how to use pip and about selecting interpreter thank you
@Overlycomplicatedswede
@Overlycomplicatedswede 25 күн бұрын
tim always dropping very easy to follow guides and i was wondering if someone had coded this i tried to on my own then found this video on got my version working after some tweeks!
@peyman_shabani
@peyman_shabani 3 күн бұрын
Great content and so clear explanation thanks Tim😊❤
@justhamza_3344
@justhamza_3344 15 күн бұрын
bro perfect tutorial keep it up | now im going to edit it by changing the colors a bit
@chandrasekars8904
@chandrasekars8904 Ай бұрын
This is really an excellent channel on Python like "techie talkee"
@viral.clips247
@viral.clips247 Ай бұрын
Hey bro I just wanted to say props to u for how good u did in that interview 4 years ago with Clement Mihailesco, I just watched the whole video again and tried to solve the same problem as you but in c++ it's a cool way to kind of get a feel for what you could expect in a real interview and I hope to get one soon enough. Btw any advice on how to land an internship at some of the sligtly bigger companies and also i'm not from the US so an in person internship isn't a possibility. Appreciate you 💜
@vaquitadaplug
@vaquitadaplug Ай бұрын
amazing!
@NikhilVerma-jk9ng
@NikhilVerma-jk9ng Ай бұрын
You are the best
@wonnor42
@wonnor42 Ай бұрын
You make great and inspiring videos, Tim. I love them a lot for new inspiration. However, I stopped at this one 39:04 and thought a bit. I probably missed the purpose of this game - dont know it. But the code is defenetely something I don't want to see in a huge project: The function get_random_pos. 1) Minor... the first two lines are of absolutely of no use (in python) 2) using a key which seems strange (unless I read all the code) into an iterable that I dont know about. 3) Worst. This function could run forever
@arnavshukla4271
@arnavshukla4271 Ай бұрын
Hi Tim! Can you please make more videos on web development?
@Parabolic_Blocks
@Parabolic_Blocks Ай бұрын
Hey Tim! I was wondering if sometime you could make a video on how to make a web application with sign-ins (maybe using Choreo or something) to which I can just add pygame applications and play them so I can share them with friends?
@timermens350
@timermens350 Ай бұрын
Very nice! Been playing it a bit on a 8x8 grid. I noticed some unwanted behaviour in certain conditions though. Sometimes three 4's f.e. merge in one 8... I think when all 4's are. moving. Haven't figured it out yet. Thought you should know. Tnx for your channel. It really helps me a lot as a hobbiist "programmer". I try to motivate the son (12yo) of my girlfriend to use his laptop not only for Fortnite, and he likes your teaching style as well. Keep it up!
@reymarckesaguirre4102
@reymarckesaguirre4102 Ай бұрын
I was thinking these days about how would I make grids in my python games. Then this tutorial came out. I am sold that Tim is a fcking mind reader.
@barebonestactical
@barebonestactical Ай бұрын
Love watching your videos I do have a question about the logic for determining tile colors though at 24:50. Obviously there’s no “right” answer but wondering why not just have the colors be a dict with the possible tile values as the keys and you could simply just get the color tuple from using the tile value as an index. Just curious for any specific reasoning or just simply the reason of just done in another way 🙂
@usamashami11
@usamashami11 Ай бұрын
Best Python Game Developer in Town 🥹 Never in my life I thought you would be able to code one of my fav. game in Python ❤
@GRSG_tech
@GRSG_tech Ай бұрын
Tim, Love you content and I appreciate it Can you please make a video on python PANDAS module
@user-vp5ql8vd4i
@user-vp5ql8vd4i Ай бұрын
Hey Tim, I was wondering if it is possible to make a scoring system in the game. I've coded the entire program and just wanna add some final touch ups!
@Adam9174X
@Adam9174X Ай бұрын
Can you make a Tutorial about OpenGL in Python ?
@samoylov1973
@samoylov1973 Ай бұрын
It would be nice, if the game gave users some kind of final score. score = sum([tile.value for tile in tiles.values()]) print(f"Your score - {score}") And not only in konsole, but in actual game board. Thanks for the tutorial. Learning.
@reymarckesaguirre4102
@reymarckesaguirre4102 Ай бұрын
So I decided to rest from this video for now, because I am getting too much info overload on the movement functionality. But I'll get back to it soon. HOWEVER, if there are anyone here, Android devs, wondering how to do this but with touch screen controls instead of keyboard, I made something that is admittedly not perfect, but a simple way to detect swiping. Here is how I detect if the user swiped up or down (go code the right and left, as well as a way to tell if the user meant to go on the y or x axis.): def main(window): clock = pygame.time.Clock() run = True tiles = generate_tiles() track_finger_x = [] track_finger_y = [] while run: clock.tick(FPS) for event in pygame.event.get(): if event.type == pygame.QUIT: run = False break elif event.type == pygame.FINGERMOTION: print("Triggered Down") track_finger_x.append(event.x) track_finger_y.append(event.y) elif event.type == pygame.FINGERUP: print("Triggered Up") if len(track_finger_y) == 0: continue elif len(track_finger_y) > 0: if track_finger_y[0] > track_finger_y[len(track_finger_y) - 1]: print("Moved up") elif track_finger_y[0] < track_finger_y[len(track_finger_y) - 1]: print("Moved down") track_finger_y.clear()
@reymarckesaguirre4102
@reymarckesaguirre4102 Ай бұрын
I also forgot to remove the print, but I used those for debug during the coding process. I couldn't find a lot of tutorials online about Pygame swipe, and the FINGERMOTION.dy object is only measuring too short distances to be of any use.
@viktor2160
@viktor2160 Ай бұрын
Hello Tim. I am having 3-4 years of experience with python, what do you recommend to do in order to improve my skills? Thank you.
@DrCognitive
@DrCognitive Ай бұрын
I'd rather see an enhanced/updated version of your high school game of mini-golf or whatever that game was. LOL That looked like simple fun.
@SouLDYNAMOX9
@SouLDYNAMOX9 Ай бұрын
What theme do you use. I love your theme
@Parabolic_Blocks
@Parabolic_Blocks Ай бұрын
I noticed at 5:43, you put "RGV" instead of "RGB," I assume that's a typo? Also, later it says PI GAME instead of PYGAME.
@user-pv5vh1fn9u
@user-pv5vh1fn9u Ай бұрын
Can you make a tutorial in htmx and flask
@rexst3ve
@rexst3ve Ай бұрын
Just to think I am currently hooked on this game at the moment :)
@yousuf_mamin5767
@yousuf_mamin5767 Ай бұрын
added game over text , escape key to restart option, now trying to display win message when 2048 is reached.
@Burro69_
@Burro69_ 17 күн бұрын
19:14
@justhamza_3344
@justhamza_3344 15 күн бұрын
also a 4 merged into a 16 but never mind🤪
@BobChess
@BobChess Ай бұрын
This game is from 2048. Far from future
@riyaops4090
@riyaops4090 Ай бұрын
game over kaha hai isme game over likha bhi to ana chaiye game chlta hi jara h
PLEASE Use These 5 Python Decorators
20:12
Tech With Tim
Рет қаралды 85 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 307 М.
SHE WANTED CHIPS, BUT SHE GOT CARROTS 🤣🥕
00:19
OKUNJATA
Рет қаралды 9 МЛН
Python As Fast as Possible - Learn Python in ~75 Minutes
1:19:41
Tech With Tim
Рет қаралды 1,7 МЛН
10 Python Comprehensions You SHOULD Be Using
21:35
Tech With Tim
Рет қаралды 93 М.
A Gentle Introduction to DSPy in Python Part 1
25:53
Learn By Building AI
Рет қаралды 2,3 М.
Create A Python API in 12 Minutes
12:05
Tech With Tim
Рет қаралды 527 М.
AI learns to play 2048
11:11
Code Bullet
Рет қаралды 10 МЛН
Async for loops in Python
16:36
mCoding
Рет қаралды 55 М.
Python Object Oriented Programming (OOP) - For Beginners
53:06
Tech With Tim
Рет қаралды 3,2 МЛН
I Was Wrong About ChatGPT Replacing Programmers
8:52
Tech With Tim
Рет қаралды 191 М.
ADVANCED Python AI Agent Tutorial - Using RAG
40:59
Tech With Tim
Рет қаралды 110 М.
All 39 Python Keywords Explained
34:08
Indently
Рет қаралды 70 М.