Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning iOS Game Development
This is the forum to discuss the Wrox book Beginning iOS Game Development by Patrick Alessi ; ISBN: 978-1-1181-0732-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS Game Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 30th, 2011, 09:07 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ok so Far.

I just bought this book a few days ago. As a C++ programmer, everything was straight forward, but as the little of the book said "Beginning". With that I fell that some of the context was misplaced.

I believe that Chapter 3 should have been chapter 2 and vice versa. Reason is because on chapter 2, there was a lot of "do this now and I'll explain it later" kinda thing, and that's kinda confusing. Like for me NSLog(@"%i",i). At the time I knew it kinda functioned like an printf of some sort, but "beginners" don't know what it means. Also the for loops and switch statements was a "type this and it will print some numbers, but I'll explain it later".

There was also a lot of "Now press enter and type i then press right 3 times.....", instead of that, you should have given the code.

I'm still on chapter 4. Will post my thoughts of the content bellow when I'm done.

PS. So far this book is ok. I can't really say much since I'm still at the beginning.

Last edited by simon66; December 30th, 2011 at 09:14 AM.
Reply With Quote
  #2 (permalink)  
Old January 4th, 2012, 05:43 AM
Registered User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey did you succeed to run the magicMind game program?

i am kinda stuck on that. it gives me some kind of "NSCSFString autoreleased with no pool"
Reply With Quote
  #3 (permalink)  
Old January 4th, 2012, 07:58 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I didn't do that part as I skipped that chapter. I can take a look at it after when I get home.
Reply With Quote
  #4 (permalink)  
Old March 11th, 2012, 04:19 PM
Authorized User
Points: 70, Level: 1
Points: 70, Level: 1 Points: 70, Level: 1 Points: 70, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by simon66 View Post
I just bought this book a few days ago. As a C++ programmer, everything was straight forward, but as the little of the book said "Beginning". With that I fell that some of the context was misplaced.

I believe that Chapter 3 should have been chapter 2 and vice versa. Reason is because on chapter 2, there was a lot of "do this now and I'll explain it later" kinda thing, and that's kinda confusing. Like for me NSLog(@"%i",i). At the time I knew it kinda functioned like an printf of some sort, but "beginners" don't know what it means. Also the for loops and switch statements was a "type this and it will print some numbers, but I'll explain it later".

There was also a lot of "Now press enter and type i then press right 3 times.....", instead of that, you should have given the code.

I'm still on chapter 4. Will post my thoughts of the content bellow when I'm done.

PS. So far this book is ok. I can't really say much since I'm still at the beginning.
I think the flow is fine. Chapter 2 is mostly to get the reader motivated than anything, like "wow I created something! Not sure how I did it, but I can't wait to find out"
Reply With Quote
  #5 (permalink)  
Old May 3rd, 2012, 03:18 PM
Registered User
Points: 14, Level: 1
Points: 14, Level: 1 Points: 14, Level: 1 Points: 14, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Flow is fine, but some aspects could use some explanations or probably simpler workarounds. Now I am struggling to understand why modulus operator is used to get random card from deck...why take result of random function and apply modulus to it?
Reply With Quote
  #6 (permalink)  
Old May 3rd, 2012, 09:32 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

The value of the random number cannot be larger than the number of cards. The modulus operator takes the number generated by random() and divides by 52 producing the remainder as a result. This number will range from 0-51, the 52 indices of the deck array. The value of random(), before applying modulus will, under most circumstances, far exceed the size of the array.

add the following bold code to the "do" loop in the Cards project and you can inspect the value of the generated random number.

Code:
    do {
        // Generate 2 random numbers to determine which cards to swap
        randomA = random() % 52;
        randomB = random() % 52;
        printf("Random is %ld",random());
This should clarify why modulus is needed; to limit the range of numbers.

Bob
Reply With Quote
  #7 (permalink)  
Old May 4th, 2012, 01:26 AM
Registered User
Points: 14, Level: 1
Points: 14, Level: 1 Points: 14, Level: 1 Points: 14, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So if I want to get random value from range I always use modulus?

at least now I understand why there was modulus. Somehow didn't get it while reading first
Thanks.

p.s.
being a noob I was first expecting to see something like:
Code:
randomA = random(52);
randomB = random(52);
which is wrong of course
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 02:31 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.