I left off my last blog post about creating Snake in Pygame with moving your player around the display screen. The next steps will be to create boundaries for the player, create the food, and make the snake grow on food consumption. When the snake runs out of bounds the game should end because it has hit a “wall” that ends the game.
pygame.init()white = (255, 255, 255)
blue = (0, 0, 255)
red = (255, 0, 0)display_width = 800
display_height = 600display = pygame.display.set_mode((display_height, display_width))x1 = display_width/2
y1 = display_height/2snake_block…
Using Pygame is a nice and simple way to create 2D games with ease. If you’re wanting to get into game development and learn more about it I suggest starting with Pygame.
The first thing to do will to be to import the
pygame library, initialize it, and create a display surface to draw on.
import pygamepygame.init()display = pygame.display.set_mode((800, 600))pygame.display.update()pygame.quit()quit()
Calling pygame.quit() and quit() will unitialize everything at the end of the program. At this point nothing will happen other than a window opening then immediately closing. …
Redux is to React like Mjollnir to Thor. While Thor is not powerless without his hammer, he is much more powerful when weilding his hammer. React and Redux should go hand in hand in every application or situation. Redux’s management of state staves React from the “prop drilling” problem that comes with React.
The importance of Redux can not be overstated. Connect gives you the ability to pass props from the global “store” to anywhere in the application, but you still have the ability to create local state for containers and components throughout the application. The createStore function given to…
The game Hangman is a simple but fun game that can pass the time. I’m gonna show you how to make an easy hangman-like game, that will greet a user and prompt them to guess a word that has been defined in the script.
First I will start off by importing the time module from Python this is not neccessary, but it gives a good flow to your script run time. Next I will take in the users name and greet the user and then prompt them to start guessing.
import timename = input("What is your name?")print("Hello, "…
This calculator is a simple calculator that will take in 3 user inputs. The first input will be the first number, the second input will be the operator, and the third will be the second number.
First thing you will want to do is set up variables to take in the input from the user. Taking in inputs from Python is about as easy as it can get, just declare input and specify what you want the output to be for your question.
num1 = input("Please input your first number: ")
op = input("Input the operation you would like to use…
The FizzBuzz problem is something you’ll hear a lot when becoming a developer. It’s a simple problem but something that can trick up new developers.
The overview is that the word “Fizz” will be printed when a number is divisible by 3, the word “Buzz” will be printed when a number is divisible by 5, and the word “FizzBuzz” will be printed when a number is divisible by 3 and 5.
The first thing you’ll want to do is print out numbers. I’ll just go to 30 for time's sake.
for i in range(0, 30):
I have just printed…
Working with Flask and React for the past month or so has been very enjoyable for me. Both are pretty user-friendly and have easy-to-read syntax. Figuring out the DELETE request however, was a bit of a challenge for me. But once I took a step back and looked at each part individually, everything became clear to me. So, I will do my best to show my thought process
Starting with the Flask API, creating a route that accepts DELETE requests is pretty simple. Define a route, and in the methods argument that is given by Python, pass in ‘DELETE’. I…
Recently I’ve been learning Flask. I have also been messing with POST requests while working on an application I’ve been putting my time into recently. The relationship between Python, Flask, and SQL makes “data manipulation” very easy. While I did struggle at first, I do like to make myself suffer and not use resources until I can no longer figure things out and move ahead.
So, this blog post will help beginners and newbies with making those POST requests to the Flask API from their React application. …
Building out a React front end that calls onto a Flask API is very concise and easy, but very powerful. You have access to a very powerful back end in Flask that works very well with databases and storing information.
Flask is a microframework for Python, it is very easy to get started with and easy set up for a simple CRUD application. Flask is very simple to set up and create a small application with, but it is also easily scalable if you want to grow your application. …
Flask is a micro web framework for creating APIs in Python. It’s very simple, but very powerful which is designed to get an application started quick and easy. Flask is very powerful, becuase it has the ability to scale up to complex applications.
Just because it is a micro web framework does not mean that the entire application has to fit into a single file, nor Flask is lacking in any aspects of functionality. Micro simply means Flask aims to keep the core simple but extensible, says the Flask documentation.
Installing Flask is very easy, I recommend using pip to…