Re:Show HN: Flappy Block – Flappy Bird clone using the iOS7 ...
by joeblau on Monday February 10, 2014 @01:21AM
(#7209459)
That is a great implementation. It seems like Nathan is using SpriteKit while my implementation uses UIDynamics. I just ran it and it seems to have collisions implemented. Mine doesn't have counters or anything extra on the screen yet, but the main challenge for me was playing with the physics engine.
Re:Show HN: Flappy Block – Flappy Bird clone using the iOS7 ...
by jey on Monday February 10, 2014 @01:24AM
(#7209469)
What do you mean by "iOS7 physics engine"? I can't imagine a game physics engine being included with the OS. Is this referring to a creative abuse of iOS UI widget animations?
Re:Show HN: Flappy Block – Flappy Bird clone using the iOS7 ...
by interpol_p on Monday February 10, 2014 @01:29AM
(#7209482)
There are two physics engines in iOS 7.
SpriteKit - Contains a 2D physics engine similar to Box 2D but not as full featured (joints, rigid bodies, shapes, polygons). The whole engine is similar to Cocos2D but ships with iOS 7. A particle editor and texture atlas generator is now built-in to Xcode because of it.
UI Dynamics - Contains a set of constraints and joints which can be used to flip and throw views around the screen. Lots of API hooks for responding to / taking user interaction into account. This is used for effects like when you scroll the messages list (the message bubbles bounce and collide) or when you drop notification center down (it bounces).
Edit: from a brief look at the source code, this example uses the UIDynamicAnimator API, so it is simulated entirely with the UI dynamics stuff.
Re:Show HN: Flappy Block – Flappy Bird clone using the iOS7 ...
by interpol_p on Monday February 10, 2014 @03:43AM
(#7209840)
Yes, that's what I meant when I said SpriteKit contains an engine similar to Box 2D. I thought my comment was reasonably clear about SpriteKit not just being the physics engine.
According to my tests it is not Box 2D, it produces significantly different results and only implements a subset of functionality. I've been told by others with more experience that it isn't Box 2D also, but if you have more information I'd like to know for sure.
Re:Show HN: Flappy Block – Flappy Bird clone using the iOS7 ...
by interpol_p on Monday February 10, 2014 @04:41AM
(#7210019)
Thanks for that, that's really interesting. It behaved differently in my experiments so I assumed it wasn't the same — but it must just be a different configuration.
Re:Show HN: Flappy Block – Flappy Bird clone using the iOS7 ...
by okamiueru on Monday February 10, 2014 @07:59AM
(#7210724)
I only heard about Flappy Bird today because of the personal story around why it was taken down.
However, this seems like just a remake of the helicopter game, which is fair enough, but hardly a feat of engineering. So, if this is the case, then what is this about using a "physics engine"? Determining if rectangles intersect seems a bit too trivial to me to be of interest, and I'm just confused what it is doing here.
Re:Show HN: Flappy Block – Flappy Bird clone using the iOS7 ...
by joeblau on Monday February 10, 2014 @09:09AM
(#7211120)
In iOS7, Apple introduced a new physics engine called UIDynamics. It's built natively into the OS which allows you to give any UIView on the screen physical properties such as Snap, Gravity, Collision, Attachments, and Pushing. Those properties, in turn, have settings like friction, density, gravitational pull, damping, elasticity, etc... The idea behind it was to make it so that you could create game style physics mechanics in any iOS application.
One example is the iOS7 notification center; If you drag it down and "slam" it to the bottom of the screen, it has some bounce. A second example is the Messages chats when scrolling quickly; You'll notice that as the swipe seed increases you get more space between peoples chat comments and they kind of slam together when you stop scrolling.
What I aimed to do here is take that same engine and use it to build FlappyBlock. So instead of having a loop that says:
while () { // Pipe is not on the left
movePipeOnePixelLeft(); // Move Pipe one pixel over
if (at the left) break; // If we hit the left, end loop
}
Physics would say something like this:
givePipeMassAndLocation(); // Give Pipe physical properties
pushPipeLeftWithForceVector(); // Push pipe to left with force
whenPipeHitsLeftWallRemove(); // Remove the pipe when it his the left
It's a different way of attacking the same problem using features many newer developers are not familiar with in iOS7.
[1]: https://github.com/nathanborror/FlapFlap
SpriteKit - Contains a 2D physics engine similar to Box 2D but not as full featured (joints, rigid bodies, shapes, polygons). The whole engine is similar to Cocos2D but ships with iOS 7. A particle editor and texture atlas generator is now built-in to Xcode because of it.
UI Dynamics - Contains a set of constraints and joints which can be used to flip and throw views around the screen. Lots of API hooks for responding to / taking user interaction into account. This is used for effects like when you scroll the messages list (the message bubbles bounce and collide) or when you drop notification center down (it bounces).
Edit: from a brief look at the source code, this example uses the UIDynamicAnimator API, so it is simulated entirely with the UI dynamics stuff.
Same thing applies to UIKit Dynamics, except it plays along with UIKit stuff.
According to my tests it is not Box 2D, it produces significantly different results and only implements a subset of functionality. I've been told by others with more experience that it isn't Box 2D also, but if you have more information I'd like to know for sure.
https://ghostbin.com/paste/tm4ko
b2* shows up in there many times.
edit: slow pony
However, this seems like just a remake of the helicopter game, which is fair enough, but hardly a feat of engineering. So, if this is the case, then what is this about using a "physics engine"? Determining if rectangles intersect seems a bit too trivial to me to be of interest, and I'm just confused what it is doing here.
One example is the iOS7 notification center; If you drag it down and "slam" it to the bottom of the screen, it has some bounce. A second example is the Messages chats when scrolling quickly; You'll notice that as the swipe seed increases you get more space between peoples chat comments and they kind of slam together when you stop scrolling.
What I aimed to do here is take that same engine and use it to build FlappyBlock. So instead of having a loop that says:
Physics would say something like this: It's a different way of attacking the same problem using features many newer developers are not familiar with in iOS7.