Pygame Tic-tac-toe Mac OS

I made some thing like this on Py Charm. Anyways this is awesome! HarethHameed 2 months ago. Im new to coding and this looks imposible to me!!!! Our Tic Tac Toe is programmed in other to allow two users or players to play the game in the same time. It is GUI game & gives an instant alert when players wins or losses or draw the game. STEPS REQUIRED TO MAKE THIS AWESOME GAME LIVE: First of all, create a folder named any in your PC & drag it to your code editor. So I’ve always wanted to try and make a sort of interactive game in python, like tic tac toe or connect 4, I know there are a lot of tutorials on grid based games but my goal was to do it all on my own. Here is the outcome. It was really difficult to work with but I think it turned out pretty good. I hope you enjoy -Dart.

Dec-26-2020, 01:51 PM
I somehow created Tic tac toe (not finished yet). when I place 'X' it place 'X' properly, and when I place 'O' it place 'O' but it also change 'X' to 'O' and then it continue to change.
I'm not able to interpret what is issue but if you run this code you will know. does anyone know how to fix this problem
Dec-27-2020, 12:45 AM (This post was last modified: Dec-27-2020, 12:46 AM by metulburr.)
You have a few bad habits as well as over-complicated processes.
bad habits:
You should not be using global keyword. You are asking for bugs.
over complicated:
It would be better to have 0 as O and 1 as X as a boolean, or whatever. Even better than that it would be better to have a dictionary or list of the positions and set them and then display them in their position for whatever the position's content is.
problem:
Your draw function is ran every iteration of the loop. This, in conjunction with you using global, means it flips back and forth for everyone, instead of how you intend it. Instead, once you set one save it in a dictionary/list, then simply just draw the entire dictionary/list.
fix with dictionary:
Which if it was a dictionary... key can be position while the value identifies it to be X or O. Set all the keys to be the positions with values set to None in the beginning. Draw the entire dictionary. Those that do not have an X or O value do not draw anything, but still retain the position in advance. When someone clicks on a square assign that position to be X or O only if it has none.
Recommended Tutorials: BBcode, Forum Rules and Instructions, How to ask smart questions, the Basics, Classes, Python Gotchas

Users browsing this thread: 1 Guest(s)
Pygame tic-tac-toe mac os update

Gaming has been fun for all of us since childhood. We all enjoy playing games. But almost all the games that we have played yet were made by someone else. But you know what would be really cool? Creating your own game. Don’t worry if you don’t know how to make one. We are here to help you. In our series of articles. We will learn how to make a game in Python Programming language and it’s one of the most famous libraries, “Pygame”.

But, what exactly is Pygame?

Pygame is a set Python Module that is designed for writing Video Games. It is a free and open-source library. And one of the most popular python library to create games and applications.

Pygame Tic-tac-toe Mac Os Catalina

It adds the functionality on top of excellent SDL Library, SDL stands for Simple DirectMedia Layer, that allows the programmers to add multimedia and create fully featured games.

It was written by Pete Shinners, and was first launched on 28th October, 2000.

And one of the main reasons that we will be using this library is that it is extremely simple and efficient. It is highly portable, that means it works on almost all the operating systems.

Does not require a GUI to use all functions. SDL provides cross-platform support to your system’s underlying multimedia hardware components, such as sound, video, mouse, keyboard, and joystick.

Extremely Portable

It supports Linux (pygame comes with most mainstream Linux distributions), Windows (95, 98, ME, 2000, XP, Vista, 64-bit Windows, etc), Windows CE, BeOS, MacOS, Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX. The code contains support for AmigaOS, Dreamcast, Atari, AIX, OSF/Tru64, RISC OS, SymbianOS and OS/2, but these are not officially supported. You can use it on handheld devices, game consoles and the One Laptop Per Child (OLPC) computer.

Mac

Easy to learn

It requires a small amount ofcode. As pygame already comes with hundreds of pre-built commands, it becomes easy for programmers to create complex games also. Now you don’t need to write thousands of lines of code to make games.

And it is modular, that means, you can use pieces of pygame separately. Want to use different sound or image library? That’s fine. With Pygame, many modules can be initialized and used separately.

You have full control over your main loop. That means, you can call pygame functions, but they don’t call your functions. This gives you greater control when using other python libraries.

Loaded with power

Pygame can also use multi-core CPUs that helps the creator to bring more functionality to their games. Selected pygame functions release the dreaded python GIL, which is something you can do from C code.

You can make 2-Dimensional games using Pygame. This is true that people love 3-Dimensional games with realistic graphics, but it totally depends upon the creator, that what type of game he/she is making. Games like “Among us” are actually popular among us. So, it completely depends upon the programmer how addictive and an interesting game he/she is making.

The relationship between Pygame and Python… like Thor and Thunder

Before starting pygame you need to have a basic understanding of python programming language, such as how to use loops, lists, etc. But it is a great module which can be used to easily create fantastic games for free.

If you create a very good game then maybe you can even release it commercially. Right now, there are not many games available in the market that are made using this library.

Pygame was made using C and Assembly language so it is quite fast.

We will be using Python to add logic and functionality to our game because Pygame cannot do that alone. Without python, your game would be like paused football match.

Improving every day by Pygame Community

Pygame is still in development. There are thousands of people who contribute to Pygame community by sending them issues and patches. The Pygame community is working very hard to make this library better every day.

Mac Os Mojave

You can also contribute to this community by sending them Bugs, patches, etc. Thee Pygame community provides fast response to reported bugs. You can do a search on their mailing list for BUG.

So, are you excited to make your first game! Hold on to your talent and endurance. Let’s do it!

Thank you for reading, if you found something wrong, please let us know. Feel free to ask anything.

Also Read: