I’m now blogging here. The URL is cooler.
First Blog Part II
I was thinking about Rambo: First Blood Part II which has to be one of the most awesome titles in movie history. If you don’t remember Rambo: First Blood Part II (RFBP2) let me just say it’s woven into my DNA, always there, subtly altering the trajectory of my life without me even realizing it.
Going almost entirely from memory, RFBP2 I think opens with Rambo’s old commander seeking Rambo out and finding him in a monastery and so creating one of the greatest action hero tropes: We need you back, Hero Guy, you’re the best that ever was.
There’s one more mission. One last mission that only Rambo can do. He’s got to go back into the jungle and rescue POWs.
So of course he goes back into the jungle to rescue the POWs. Along the way he gets captured and tortured by Evil Dudes. They want him to call in to the guys who sent him in, I forget the exact context. He gets tortured until he agrees to get on the radio. He gets on the radio and… well…
He threatens to kill the traitor then beats the crap out of the Evil Dudes. My mind was blown as a kid. Blown. They thought they’d broken him but in fact he had not been broken! Surprise suckers! You’ve been Rambo’d.
I’ve always had an intense relationship in media with the ideas of torture and coercion. It’s a terrifying concept to me, the idea of being broken down until you can only do what your captors want. That’s probably why I was fascinated with Victor Frankl’s Man’s Search for Meaning. I think as a kid, and maybe all kids feel this way, I felt extremely powerless in a crazy world. The fact that Rambo didn’t give up, even after they had him and the odds were stacked against him, was really uplifting to me. To fight on even if they were bigger and stronger than you. That resonated with something in me and still does to this day.
Yeah, it’s an 80s action movie. And, yeah, in Rambo 3: Second Blood Part I he does go to Afghanistan and helps the Mujahadeen against the Soviets. But a part of me carried that scene with me to this day and even though I sometimes got pretty low in life, it’s possible that a part of me believed that maybe, just maybe, I could be a little like Rambo and keep going.
A list of movie titles that are the first and last name of the protagonist
Peter Pan
Mary Poppins
Barry Lyndon
Crocodile Dundee
Robinson Crusoe
Vera Drake
Michael Collins
Oliver Twist
Osmosis Jones
Ned Kelly
Jack Frost
Jane Eyre
Johnny Mnemonic
Nanny McPhee
Richie Rich
Donnie Brasco
Napoleon Dynamite
Marie Antoinette
Donnie Darko
Dick Tracy
Edward Scissorhands
Jack Reacher
John Wick
Jerry MacGuire
Forrest Gump
Erin Brokovich
Aeon flux
Ed Wood
Max Payne
Ellie Parker
Sherlock Holmes
Rocky Balboa
Barton Fink
Dorian Gray
Jeremiah Johnson
John Carter
August Rush
Billy Elliott
Annie Hall
Solomon Kane
Dolores Claiborne
Robin Hood
Jackie Brown
50 Shades of Reacher
I was wondering if Jack Reacher is really just 50 Shades of Gray for a different demographic. If it’s like 50 Shades for grandpas. The reason I started thinking about this was a discussion about the outrageous success of the 50 Shades franchise, and I noticed that Jack Reacher seemed incredibly successful.
I’m going to take a second to check Box Office Mojo:
| $413,773,840 |
| $218,340,595 |
Oh man! Jack Reacher has already made around only half of what 50 Shades has made! Which I find sad because I’ve argued many times that Jack Reacher is actually a good movie. It’s a well filmed, well acted movie based on a ridiculous story, but seriously it’s probably one of the best 80s action movies that has been released in a long time.
So my reasons to compare them is that I think of Jack Reacher as a power trip fantasy for your right wing conservative grandpa. Jack is this libertarian ubermensch who bows to no master but what he perceives is right, and cannot be shackled by The Man or even The WoMAN. Jack is also the coolest guy who has ever lived, dropping grandpa jokes all over town, and beating up young hooligans who think they’re cool (spoiler: they’re not cool).
50 Shades also seems to be at its heart a kind of power fantasy, but it’s kind of like an inversion of Jack Reacher. It’s like, there exists an unstoppable, irrational power, that is directed at a person who is powerless except for this hold they have on this high potency male. I haven’t read the book, I should note, I’ve only read about the book, but from what I’ve read I’d rather read Twilight. Because at least Twilight has vampires.
I’ll have to think more on it, but at least I’ve learned that 50 Shades of Gray is way more successful than Jack Reacher.
Teenage Wasteland 2
I’ve started playing Wasteland 2 and I’m having a blast. It’s an isometric two-dimensional turn-based tactical post-apocalyptic role-playing game set in the Southwest of the USA after a devastating war. Basically, it’s like playing Fallout 2 all over again. Fallout 2 came into my life in a very troubling period of my life. I was always looking for some kind of escape from problems I didn’t understand and Fallout 2 offered me that escape to a world that was dark and devastated, but had the glimmer of hope. As the Chosen One in Fallout 2 I could make things better for the people of the Wastes. The amazing thing about Fallout 2, one of the amazing things anyway, was the post-game recap where you could see the consequences of your actions. And it always felt good knowing that you helped some people and left that world a better place. Real life, at the time, didn’t offer those same opportunities.
So now I feel I have returned to the Wastes after decades away. I come back less looking for escapism, and yet in the Wastes I find the same feelings stirring in me that I left a long time ago. I’m not a child looking to escape anymore, so when I come to the Wastes now I simply find the joy of returning to an old playground. Wasteland 2 is a grim game, much darker perhaps than Fallout 2, but I still see the hope that runs through the heart of it. Though the world is ruined, people can make it better.
And that’s when I rediscovered something I forgot I had: a love for games. It’s not just an addiction or a distraction, or at least it wasn’t always so, but it was actually a true art that had a positive impact on my life in some ways.
Maybe this means I’ll think about getting into game development. Maybe it just means I can have a good time with the kid I used to be.
Curb Your Enthusiasm, Community
“I should write an essay about Larry David being the modern Odysseus.” -My roommate
I started watching Curb Your Enthusiasm and it is a continuation of the Seinfeld experience. I enjoyed the first few seasons but I don’t think the show really became brilliant until the Seinfeld reunion season. The Producers season was really good, but I feel like the show is just on now and I feel like it’s the best season yet.
I’ve watched pieces of Community and Curb Your Enthusiasm and I keep speculating that there’s a connection. Dan Harmon, creator of Community is too big a tv and sitcom nerd not to know and love Seinfeld. There’s meta-humor in Curb that is not unlike the meta-humor that is in Community but there’s a difference there that I have yet to fully be able to articulate. My best guess is that Communityhas to nod and wink at the camera but Curbjust plays it absolutely straight. I think the difference comes down to skill level, Dan Harmon and Larry David use the formula, but while Dan approaches it from a loving mockery position, Larry is just a master of the formula. It’s an interesting comparison and I plan on thinking about it some more.
Oh hi vectors. We went to college together, remember?
I’ve studied a lot of physics in my time so this is a pretty nice review. None of this is really new for me (in fact I think I’ve learned it multiple times) but it’s nice to see it’s applications in a programming/gaming sense.
For example, you can use dot products to tell if you’re facing something or not. Not exactly exciting but I can definitely see the use for it.
Not much done tonight. I’m pretty wiped out. Tomorrow night or Wednesday I’m just going to vector up my program.
I realize there are lots of gaps in my knowledge. I’ll probably try and do some backtracking this week.
Doing it better
I was working on creating functions to handle some of the more repetitive aspects of my code. I finally got one to work but it required a list of rectangles, a rectangle I’m checking, and two lists of coordinates (one for x and one for y).
This allowed me to check if each rectangle in the list collides with the solo rectangle I put in there, and if so, then it alters the solo rectangle by the amount given by the two lists of coordinates (here’s an example):
def collisioncheck (list_of_rects, rectangle, list_x, list_y):
for i in range(len(list_of_rects)):
if list_of_rects[i].colliderect(rectangle):
rectangle.x = rectangle.x + list_x[i]
rectangle.y = rectangle.y + list_y[i]
I also clamped down my angles by using modulo (%):
angle = (angle + 0.1) % (2 * pi)
It took a long time to work out bugs, but I finally got it to work and it’s pretty cool.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import a library of functions called ‘pygame’ | |
| import pygame | |
| from math import pi | |
| from math import cos | |
| from math import sin | |
| from math import atan | |
| # Initialize the game engine | |
| pygame.init() | |
| # Define the colors we will use in RGB format | |
| BLACK = ( 0, 0, 0) | |
| WHITE = (255, 255, 255) | |
| RED = (255, 0, 0) | |
| # Set the height and width of the screen | |
| size = [1200, 600] | |
| screen = pygame.display.set_mode(size) | |
| #pygame.display.set_caption(“PONG”) | |
| # Setting the starting angles for the satellite blocks so they don't overlap | |
| circle_angle = 0 | |
| circle_angle_2 = (1/3) * 2 * pi | |
| circle_angle_3 = (2/3) * 2 * pi | |
| # Generating starting positions | |
| circle_move_x = 0 | |
| circle_move_y = 0 | |
| circle_move_x_2 = 50 * cos(circle_angle_2) | |
| circle_move_y_2 = 50 * cos(circle_angle_2) | |
| circle_move_x_3 = 50 * sin(circle_angle_3) | |
| circle_move_y_3 = 50 * sin(circle_angle_3) | |
| # create objects | |
| block = pygame.draw.rect(screen, WHITE, [300, 10, 50, 20]) | |
| block_ball = pygame.draw.rect(screen, WHITE, [300, 10, 10, 10]) | |
| block_ball_2 = pygame.draw.rect(screen, RED, [300, 10, 10, 10]) | |
| block_ball_3 = pygame.draw.rect(screen, RED, [300, 10, 10, 10]) | |
| second_block = pygame.draw.rect(screen, RED, [size[0] / 2, size[1] / 2, 50, 50]) | |
| # I need this for my collision check function. This is a list of rects. | |
| list_rects = [block_ball, block_ball_2, block_ball_3] | |
| # Created this function to check collisions with my satellite blocks. listx and listy are the coordiantes calculating where | |
| # the circle motion of the blocks are. I'm hoping that gives it some kind of realistic motion. | |
| def collision_check (list_of_rects, single_block, listx, listy): | |
| for i in range(len(list_of_rects)): | |
| if list_of_rects[i].colliderect (single_block): | |
| single_block.x = single_block.x + listx[i] | |
| single_block.y = single_block.y + listy[i] | |
| print ("collide") | |
| # Variables to check what key is being depressed. | |
| pressing_right = False | |
| pressing_left = False | |
| pressing_up = False | |
| pressing_down = False | |
| pressing_a = False | |
| #Loop until the user clicks the close button. | |
| done = False | |
| clock = pygame.time.Clock() | |
| while not done: | |
| # This limits the while loop to a max of 10 times per second. | |
| # Leave this out and we will use all CPU we can. | |
| clock.tick(10) | |
| # Checks for input. | |
| # event.type covers if a key is depressed (KEYDOWN or KEYUP). | |
| # event.key checks WHAT key is depressed. | |
| for event in pygame.event.get(): # User did something | |
| if event.type == pygame.QUIT: # If user clicked close | |
| done=True # Flag that we are done so we exit this loop | |
| if event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT: | |
| pressing_right = True | |
| if event.type == pygame.KEYUP and event.key == pygame.K_RIGHT: | |
| pressing_right = False | |
| if event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT: | |
| pressing_left = True | |
| if event.type == pygame.KEYUP and event.key == pygame.K_LEFT: | |
| pressing_left = False | |
| if event.type == pygame.KEYDOWN and event.key == pygame.K_UP: | |
| pressing_up = True | |
| if event.type == pygame.KEYUP and event.key == pygame.K_UP: | |
| pressing_up = False | |
| if event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN: | |
| pressing_down = True | |
| if event.type == pygame.KEYUP and event.key == pygame.K_DOWN: | |
| pressing_down = False | |
| # All drawing code happens after the for loop and but | |
| # inside the main while done==False loop. | |
| # Clear the screen and set the screen background | |
| screen.fill(BLACK) | |
| # Draw rectangles | |
| pygame.draw.rect(screen, WHITE, block) | |
| pygame.draw.rect(screen, WHITE, block_ball) | |
| pygame.draw.rect(screen, RED, block_ball_2) | |
| pygame.draw.rect(screen, WHITE, block_ball_3) | |
| pygame.draw.rect(screen, RED, second_block) | |
| # Calculate orbiting positions | |
| circle_move_x = 50 * cos(circle_angle) | |
| circle_move_y = 50 * sin(circle_angle) | |
| # Clamping to circle angle using the modulo (%). | |
| # The % will always return the remainder which is all that should matter for the angle. | |
| circle_angle = (circle_angle + 0.1) % (2 * pi) | |
| circle_move_x_2 = 50 * cos(circle_angle_2) | |
| circle_move_y_2 = 50 * sin(circle_angle_2) | |
| circle_angle_2 = (circle_angle_2 + 0.1) % (2 * pi) | |
| circle_move_x_3 = 50 * cos(circle_angle_3) | |
| circle_move_y_3 = 50 * sin(circle_angle_3) | |
| circle_angle_3 = (circle_angle_3 + 0.1) % (2 * pi) | |
| # This is a list of x and y coordinates for my check collision function. | |
| circle_move_xlist = [circle_move_x, circle_move_x_2, circle_move_x_3] | |
| circle_move_ylist = [circle_move_y, circle_move_y_2, circle_move_y_3] | |
| # Position the rectangles around block | |
| block_ball.center = (block.centerx + circle_move_x, block.centery + circle_move_y) | |
| block_ball_2.center = (block.centerx + circle_move_x_2, block.centery + circle_move_y_2) | |
| block_ball_3.center = (block.centerx + circle_move_x_3, block.centery + circle_move_y_3) | |
| # clamping angle to circle | |
| # if circle_angle > 2 * pi: | |
| # circle_angle = circle_angle – 2 * pi | |
| #if circle_angle_2 > 2 * pi: | |
| # circle_angle_2 = circle_angle_2 – 2 * pi | |
| #if circle_angle_3 > 2 * pi: | |
| # circle_angle_3 = circle_angle_3 – 2 * pi | |
| # update rectangle | |
| # Pressing Right Arrow makes it go Right. | |
| if pressing_right: | |
| block.x += 5 | |
| # Checking here for collisions with the main block since it's something I couldn't put in the collision_check function. | |
| if block.colliderect(second_block): | |
| second_block.x += 5 | |
| # Pressing Left Arrow makes it go Left. | |
| if pressing_left: | |
| block.x = block.x – 5 | |
| if block.colliderect(second_block): | |
| second_block.x = second_block.x – 5 | |
| # Pressing Up Arrow makes it go up. | |
| # Had to minus to get it to go up. It’s counter-intuitive. | |
| # I’m not sure if I’m missing something. | |
| if pressing_up: | |
| block.y = block.y – 5 | |
| if block.colliderect(second_block): | |
| second_block.y = second_block.y – 5 | |
| # Adding a constant makes it go down. I don’t know why. | |
| if pressing_down: | |
| block.y = block.y + 5 | |
| if block.colliderect(second_block): | |
| second_block.y = second_block.y + 5 | |
| # check if block collides with second_block | |
| """if block_ball.colliderect(second_block): | |
| second_block.x = second_block.x + circle_move_x | |
| second_block.y = second_block.y + circle_move_y | |
| print("Collides!") | |
| if block_ball_2.colliderect(second_block): | |
| second_block.x = second_block.x + circle_move_x_2 | |
| second_block.y = second_block.y + circle_move_y_2 | |
| print("Collides!") | |
| if block_ball_3.colliderect(second_block): | |
| second_block.x = second_block.x + circle_move_x_3 | |
| second_block.y = second_block.y + circle_move_y_3 | |
| print("Collides!") | |
| if block.colliderect(second_block): | |
| block.x = block.x – 15 | |
| block.y = block.y – 15""" | |
| # Replacing the code above with this function here. | |
| collision_check (list_rects, second_block, circle_move_xlist, circle_move_ylist) | |
| # Go ahead and update the screen with what we’ve drawn. | |
| # This MUST happen after all the other drawing commands. | |
| pygame.display.flip() | |
| # Be IDLE friendly | |
| pygame.quit() |
The Best Superman Villain: Diner Man
Like usual, I was thinking about Superman II: The Richard Donner Cut. If you’re a fan of the original Donner Superman movies, you definitely owe it to yourself to check out the Donner Cut of Superman II. I realized that perhaps the most significant villain in all the Superman movies is actually Rocky, or as I like to call him: Diner Man.
This scene is dark even in the Lester cut of the movie. Superman is beaten up in front of his girlfriend by a nobody. Diner Man is just a bully. He is not a super villain who is going to conquer the world and does not have super powers. He’s just a mortal man, and a petty and cruel mortal man, who is hurting someone because he can. And it’s Superman’s first real taste of any of that.
Ironically, it’s Rocky who may have helped save the world when Superman realizes perhaps life isn’t worth living in a world with Rockies and no Superman.
What makes this ending fantastic is that in the Donner Cut, Superman reverses time and the events of the movies never happened. That means Superman goes to a diner where Rocky is and confronts him over something that Rocky never did and has no memory of doing.
It also fascinates me that Superman’s traditional human nemesis, Lex Luthor, is someone that he holds no real rancor towards. Luthor had tried to kill him and betray him numerous times in just two movies, but the only sense you get from Superman is kind of a tried patience. He never harms Luthor.
But it’s different with Diner Man. Superman confronts him as Clark Kent, his powerless alter ego, but this time he doesn’t bother hiding his powers. He beats up Diner Man and humiliates him, and he does it as Clark Kent. I think that’s because this isn’t Superman, Superman is above that kind of pettiness, but the part of him that is human did what any person would do given Superman’s powers, he’d get revenge.
So in that sense, as a mortal man who actually earned Superman’s hatred, Diner Man is a significant character in the mythos of Superman. Diner Man brought Superman down to his level for a moment.
Boxes Collide!
I learned about Gist today. It’s a useful tool for posting code in blog posts like this. My coworker had to spend about twenty minutes figuring out the code he copied & pasted from the last post with code in it. The formatting errors are a real headache.
I also now know about this subreddit which is reportedly very handy for novice programmers.
My project for this weekend was to make two blocks collide. That turned out to be easy thanks to pygames:
colliderect()
test if two rectangles overlap
colliderect(Rect) -> bool
What this means is that if I put a rectangle into the space marked Rect, I get a boolean. A boolean is just a true or false statement. If colliderect returns true than two rectangles collide, if not then they’re not colliding.
So I did that. Then I thought, “Why not have the blocks react?” So I had my static block (called second_block) move whenever it was hit, and moved in the x and y direction derived from the block that hit it. That was just laziness on my part.
Then I did another thing I’ve been dying to do: I put three orbiting blocks around a larger block. It took a long time to offset them correctly and I’m still not sure if I got it right. They have to start in different positions or you won’t be able to see them, and you want them to be equidistant from each other, so I ended up using 2/3 * pi and 4/3 * pi and 0.
It worked really well. Then I made everything collide with one block. Then I made the block I could move jump back when it collides. It’s hard to describe but it’s really cool.
NOTE:
You might notice all the repetition of if statements on rectangles. My inclination is to make a list of rectangles and then have a function that takes a list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import a library of functions called ‘pygame’ | |
| import pygame | |
| from math import pi | |
| from math import cos | |
| from math import sin | |
| # Initialize the game engine | |
| pygame.init() | |
| # Define the colors we will use in RGB format | |
| BLACK = ( 0, 0, 0) | |
| WHITE = (255, 255, 255) | |
| RED = (255, 0, 0) | |
| # Set the height and width of the screen | |
| size = [1200, 600] | |
| screen = pygame.display.set_mode(size) | |
| #pygame.display.set_caption(“PONG”) | |
| # Setting the starting angles for the satellite blocks so they don't overlap | |
| circle_angle = 0 | |
| circle_angle_2 = (1/3) * 2 * pi | |
| circle_angle_3 = (2/3) * 2 * pi | |
| # Generating starting positions | |
| circle_move_x = 0 | |
| circle_move_y = 0 | |
| circle_move_x_2 = 50 * cos(circle_angle_2) | |
| circle_move_y_2 = 50 * cos(circle_angle_2) | |
| circle_move_x_3 = 50 * sin(circle_angle_3) | |
| circle_move_y_3 = 50 * sin(circle_angle_3) | |
| # create objects | |
| block = pygame.draw.rect(screen, WHITE, [300, 10, 50, 20]) | |
| block_ball = pygame.draw.rect(screen, WHITE, [300, 10, 10, 10]) | |
| block_ball_2 = pygame.draw.rect(screen, RED, [300, 10, 10, 10]) | |
| block_ball_3 = pygame.draw.rect(screen, RED, [300, 10, 10, 10]) | |
| second_block = pygame.draw.rect(screen, RED, [size[0] / 2, size[1] / 2, 50, 50]) | |
| # Variables to check what key is being depressed. | |
| pressing_right = False | |
| pressing_left = False | |
| pressing_up = False | |
| pressing_down = False | |
| pressing_a = False | |
| #Loop until the user clicks the close button. | |
| done = False | |
| clock = pygame.time.Clock() | |
| while not done: | |
| # This limits the while loop to a max of 10 times per second. | |
| # Leave this out and we will use all CPU we can. | |
| clock.tick(10) | |
| # Checks for input. | |
| # event.type covers if a key is depressed (KEYDOWN or KEYUP). | |
| # event.key checks WHAT key is depressed. | |
| for event in pygame.event.get(): # User did something | |
| if event.type == pygame.QUIT: # If user clicked close | |
| done=True # Flag that we are done so we exit this loop | |
| if event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT: | |
| pressing_right = True | |
| if event.type == pygame.KEYUP and event.key == pygame.K_RIGHT: | |
| pressing_right = False | |
| if event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT: | |
| pressing_left = True | |
| if event.type == pygame.KEYUP and event.key == pygame.K_LEFT: | |
| pressing_left = False | |
| if event.type == pygame.KEYDOWN and event.key == pygame.K_UP: | |
| pressing_up = True | |
| if event.type == pygame.KEYUP and event.key == pygame.K_UP: | |
| pressing_up = False | |
| if event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN: | |
| pressing_down = True | |
| if event.type == pygame.KEYUP and event.key == pygame.K_DOWN: | |
| pressing_down = False | |
| # All drawing code happens after the for loop and but | |
| # inside the main while done==False loop. | |
| # Clear the screen and set the screen background | |
| screen.fill(BLACK) | |
| # Draw rectangles | |
| pygame.draw.rect(screen, WHITE, block) | |
| pygame.draw.rect(screen, WHITE, block_ball) | |
| pygame.draw.rect(screen, RED, block_ball_2) | |
| pygame.draw.rect(screen, WHITE, block_ball_3) | |
| pygame.draw.rect(screen, RED, second_block) | |
| # Calculate orbiting positions | |
| circle_move_x = 50 * cos(circle_angle) | |
| circle_move_y = 50 * sin(circle_angle) | |
| circle_angle += 0.1 | |
| circle_move_x_2 = 50 * cos(circle_angle_2) | |
| circle_move_y_2 = 50 * sin(circle_angle_2) | |
| circle_angle_2 += 0.1 | |
| circle_move_x_3 = 50 * cos(circle_angle_3) | |
| circle_move_y_3 = 50 * sin(circle_angle_3) | |
| circle_angle_3 += 0.1 | |
| # Position the rectangles around block | |
| block_ball.center = (block.centerx + circle_move_x, block.centery + circle_move_y) | |
| block_ball_2.center = (block.centerx + circle_move_x_2, block.centery + circle_move_y_2) | |
| block_ball_3.center = (block.centerx + circle_move_x_3, block.centery + circle_move_y_3) | |
| # clamping angle to circle | |
| if circle_angle > 2 * pi: | |
| circle_angle = circle_angle – 2 * pi | |
| if circle_angle_2 > 2 * pi: | |
| circle_angle_2 = circle_angle_2 – 2 * pi | |
| if circle_angle_3 > 2 * pi: | |
| circle_angle_3 = circle_angle_3 – 2 * pi | |
| # update rectangle | |
| # Pressing Right Arrow makes it go Right. | |
| if pressing_right: | |
| block.x += 5 | |
| # Pressing Left Arrow makes it go Left. | |
| if pressing_left: | |
| block.x = block.x – 5 | |
| # Pressing Up Arrow makes it go up. | |
| # Had to minus to get it to go up. It’s counter-intuitive. | |
| # I’m not sure if I’m missing something. | |
| if pressing_up: | |
| block.y = block.y – 5 | |
| # Adding a constant makes it go down. I don’t know why. | |
| if pressing_down: | |
| block.y = block.y + 5 | |
| # check if block collides with second_block | |
| if block_ball.colliderect(second_block): | |
| second_block.x = second_block.x + circle_move_x | |
| second_block.y = second_block.y + circle_move_y | |
| print("Collides!") | |
| if block_ball_2.colliderect(second_block): | |
| second_block.x = second_block.x + circle_move_x_2 | |
| second_block.y = second_block.y + circle_move_y_2 | |
| print("Collides!") | |
| if block_ball_3.colliderect(second_block): | |
| second_block.x = second_block.x + circle_move_x_3 | |
| second_block.y = second_block.y + circle_move_y_3 | |
| print("Collides!") | |
| if block.colliderect(second_block): | |
| block.x = block.x – 15 | |
| block.y = block.y – 15 | |
| # Go ahead and update the screen with what we’ve drawn. | |
| # This MUST happen after all the other drawing commands. | |
| pygame.display.flip() | |
| # Be IDLE friendly | |
| pygame.quit() |