Author: Steven Lipton
-
from Apple to Raspberry Pi: Making Classes in Python
Objective-C and Python are similar when it comes to defining new classes, but be careful with their differences. In Objective-C we would define a class with two files: a header and an implementation file. In the header we would declare properties like this And possibly public methods In the implementation file we would have the…
-
From Apple to Raspberry Pi: Transitioning into Functions.
When I started Making App Pie, one of my big frustrations was wrapping my head around defining methods. I was used to C++ and Java functions. Objective-C and its Smalltalk roots just threw me. Now going into Python is difficult too — but for another reason. Once again dynamic typing in Python rears up to…
-
The Slippy Flippy Dare: How to Use Basic Physics in Sprite Kit
In the last installment of this series I showed two kinds of animation: SKAction and using the update: method from frame animation. The third major type of animation is using the physics engine. A physics engine takes the mathematical laws of physics and adds them to the scene. It removes the developer from the math…
-
From Apple to Raspberry Pie: Python For Loops
Python for loops is, loopy. C, Objective-C, Java and most other languages use a for loop that is numerical. This code will count the numbers, and when the numbers are greater than 5, will stop. Python is different. The for loop is more like fast enumeration in Objective-C than a counting loop. Python lists individual…
-
From Apple to Raspberry Pi: While Loops
In Xcode, both in Objective-C and C, we have the while loop. The python equivalent is also while Since we already understand the block, know sometimes as a suite in Python, while loops in Python are very simple to use. We can use break in a loop to break execution. This is a valid loop…
-
The Slippy Flippy Challenge: How to Move a Sprite
Back in February, I bragged once that I could put together Flappy Bird in a week. Someone called my bluff, and I was challenged to do so. I did put together a game like Flappy Bird, and now I’ll show you how I did it. Last time we put a sprite of a penguin on…
-
Apple to Raspberry Pi: Python’s If
In Objective-C, we would write an if statement like this: if(number1 == number2){ NSLog(@”equal”); } in Python it is this: if number1==number2 : print(‘equal’) There is no parentheses required around the logical expression. Instead of the {} to show the block to run, a colon (:) and indentations find the code to run. Note that…