Trigonometry for Game Programming: Part 1/2

Discussion of the official tutorials published on raywenderlich.com. Please only discuss the official tutorials here - for general questions, use the General Discussion forum instead.

Trigonometry for Game Programming: Part 1/2

This is the official thread to discuss the following blog post: Trigonometry for Game Programming: Part 1/2
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - -

rwenderlich

Posts: 2344
Joined: Thu Dec 23, 2010 4:14 pm
Has thanked: 28 times
Been thanked: 418 times

Re: Trigonometry for Game Programming: Part 1/2

You guys keep surprising me and it is just amazing what kind of high quality stuff you release

Awesome work! Will have a read trough over the weekend, just skimmed it now, and found it very enlighting
Hannu
Uber Haxx0r

Posts: 58
Joined: Sat Jul 16, 2011 12:39 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Trigonometry for Game Programming: Part 1/2

Thank you for this tutorial. It was a very interesting read and actually proved to be an inspiration to a problem I was facing in a current project!

Thanks again!

Orochi_X
Uber Haxx0r

Posts: 58
Joined: Sat Jul 02, 2011 1:14 pm
Location: Kidderminster, United Kingdom
Has thanked: 1 time
Been thanked: 1 time

Re: Trigonometry for Game Programming: Part 1/2

The ability of modern hardware to handle this kind of thing really surprised me. Coming from a background of doing browser software on mobile devices, where OEMs would refuse to allow any floating point code and even decoding animated GIFs was a major optimization hurdle, I set about my first game project - which was moving units around a map following a path traced by a finger, like Flight Control - with the expectation that no floats or trigonometry could be used. I started doing things with approximated integers and lookup tables for sin and cos functions like I used to.

I was amazed when I tried an experiment and couldn't detect any slowdown at all, not with way more units and paths than I ever expected to need. The power in our pockets...

aeberbach
Forum Subject Matter Expert

Posts: 1407
Joined: Sat Feb 19, 2011 5:37 am
Has thanked: 13 times
Been thanked: 194 times

Re: Trigonometry for Game Programming: Part 1/2

aeberbach wrote:The ability of modern hardware to handle this kind of thing really surprised me. Coming from a background of doing browser software on mobile devices, where OEMs would refuse to allow any floating point code...

Interestingly enough, even OpenGL ES 2.0 has support for devices that cannot do floating point. On the iPhone, however, using fixed point instead of floating point is a lot slower.
Like card games? Play my new game Mahjong Cards for iPad.

Hollance
Subscriber since Jan 26, 2014
iOS Tutorial Team Member

Posts: 5623
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 947 times

Re: Trigonometry for Game Programming: Part 1/2

Hi Matthijs!
I'm not sure what I'm doing wrong but I can't even complete the "convert to ARC" step of the tutorial. I realize I could skip ahead and use your sample project but I was hoping to build it from scratch. I'm using Xcode version 4.6.2 and the latest Cocos2d (2.1-rc1). I was able to build and run the basic "game" without any issue. When I attempt to refactor for ARC, I get 21 errors and 8 warnings. It says I have to fix all ARC readiness issues and try again. Is there a simple fix for this? Thanks!
wags
n00b

Posts: 3
Joined: Tue Mar 26, 2013 2:35 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trigonometry for Game Programming: Part 1/2

In case anyone else is having trouble with the ARC conversion, the beginning steps of the guide here seem to clear things up.
http://www.raywenderlich.com/23854/arc-and-cocos2d-v2-x
wags
n00b

Posts: 3
Joined: Tue Mar 26, 2013 2:35 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trigonometry for Game Programming: Part 1/2

wags wrote:When I attempt to refactor for ARC, I get 21 errors and 8 warnings. It says I have to fix all ARC readiness issues and try again. Is there a simple fix for this? Thanks!

Are you trying to convert the entire project? You're only supposed to convert main.m, AppDelegate.m, HelloWorldLayer.m and IntroLayer.m.
Like card games? Play my new game Mahjong Cards for iPad.

Hollance
Subscriber since Jan 26, 2014
iOS Tutorial Team Member

Posts: 5623
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 947 times

Re: Trigonometry for Game Programming: Part 1/2

Hollance wrote:
wags wrote:When I attempt to refactor for ARC, I get 21 errors and 8 warnings. It says I have to fix all ARC readiness issues and try again. Is there a simple fix for this? Thanks!

Are you trying to convert the entire project? You're only supposed to convert main.m, AppDelegate.m, HelloWorldLayer.m and IntroLayer.m.

Yes, I believe I was. Perhaps I'm using the "refactor" option incorrectly. I thought that it always affected the entire project.
wags
n00b

Posts: 3
Joined: Tue Mar 26, 2013 2:35 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Trigonometry for Game Programming: Part 1/2

wags wrote:Perhaps I'm using the "refactor" option incorrectly. I thought that it always affected the entire project.

It does. It converts the entire project to ARC. However, for the files you do not select, it adds a compiler option that tells the compiler not to use ARC for these files. That's what you want to have happen for the files from Cocos2D. So even though the project is now ARC, the files from Cocos2D are treated as an exception and are compiled with ARC disabled.
Like card games? Play my new game Mahjong Cards for iPad.

Hollance
Subscriber since Jan 26, 2014
iOS Tutorial Team Member

Posts: 5623
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 947 times

Next