|
sevenflow posted:The only issue with this is that you won't be able to really project before hand, you'll have to test on every frame. Which is fine, it's a really cheap operation. Wouldn't that be a preferred design anyway? It saves a lot of re-writing if the game ever has to test for collisions against objects that are moving.
|
# ? Apr 13, 2011 16:44 |
|
|
# ? May 15, 2024 03:19 |
|
Yeah, I think it is in most cases. He wasn't entirely clear as to how he was using it, though, so I was just wondering if maybe he was doing pathfinding or something similar and wanted to pre-check if the path was feasible before the player ever moved. For a platformer or the like it's ideal. You could also go with something like Box2D for collision detection, even if you're not using it for physics simulation. It has a lot of nice functionality built in for testing these types of things (eg. it'll let you project the path of an object and let you know all the objects it will collide with on the way.)
|
# ? Apr 13, 2011 16:47 |
|
Bob Morales posted:Is there any reason not to do stuff like puzzle games in just plain UIKit? Not really. UIKit is fine for a simple puzzle game. I think goon made Scoops was made with UIKit mostly.
|
# ? Apr 13, 2011 23:18 |
|
Bob Morales posted:Is there any reason not to do stuff like puzzle games in just plain UIKit? Nope, if CoreAnimation is good enough then you can feel free. UIKit draws with OpenGL under the hood anyway.
|
# ? Apr 14, 2011 02:48 |
|
sevenflow posted:The only issue with this is that you won't be able to really project before hand, you'll have to test on every frame. Which is fine, it's a really cheap operation. I don't understand why I'd need to test every frame? Can't I just use a for loop before the player starts moving? I'd much rather use timers in a lot of cases, but yeah I didn't know how much that would slow down things. Here I do a test of where the rects would be by overriding the draw method in cocos2D: There, they are 32 pixels apart from their centers, but I may want to do as little as 8 to get rid of those hard edges and make it more accurate. I might figure out a way to avoid redundant checking. But yes, this has all been very daunting and I think I'd just like to check per frame. This also means that anything else that needs to check for collision (such as enemies hitting walls) would need to check every frame. xzzy posted:Wouldn't that be a preferred design anyway? It saves a lot of re-writing if the game ever has to test for collisions against objects that are moving. Exactly. Again the only thing I've been afraid of is retaining speed. sevenflow posted:You could also go with something like Box2D for collision detection, even if you're not using it for physics simulation. It has a lot of nice functionality built in for testing these types of things (eg. it'll let you project the path of an object and let you know all the objects it will collide with on the way.) That's nice to know, but how much would it slow it down compared to checking per frame? So I guess what I'd really like to get peoples opinions on is what should I use: -A path of rects to precheck collision before movement -Check collision per frame (I think I'd prefer this, but speed? Also could I get some idea of how this is done) -Use Box 2D (Unnecessary?)
|
# ? Apr 15, 2011 17:09 |
|
NOG posted:-A path of rects to precheck collision before movement Pre-checking can get really expensive, as scene complexity rises, the check will have to spend more time testing everything. Runs the risk of getting to a point where a player clicking results in a perceptible drop in framerate before action resumes (if you've ever played Dwarf Fortress, this is one of the biggest performance hits in the game, entities picking their route before doing it). Per frame checks are well-studied and there is a lot of discussion out there on how to optimize them. It is true that testing every single frame will increase render time, but you're spreading the workload over a span of several seconds.. which translates into a smoother performance with fewer spikes. I don't really have an opinion on box2d, I've experimented with it and it seems able to handle a hundred or more physics objects without breaking a sweat, so I'm sure it would work, but on the other hand, you miss out on the educational aspect of doing your own collision.
|
# ? Apr 15, 2011 17:28 |
|
Thanks. I'm going to see how a per-frame basis works out and how much I can push it. Does anyone know if ccTime checks on a per frame? Even after looking it up on the Cocos2D site, I can't really find out much info about it. Just calling this in init: [self schedule:@selector(update:)]; And this as a method code:
|
# ? Apr 15, 2011 19:25 |
|
NOG posted:Thanks. I'm going to see how a per-frame basis works out and how much I can push it. The "dt" will be the time since the last call. So if you're updating position it should look like code:
|
# ? Apr 15, 2011 20:02 |
|
So how can you have a method checked every frame? edit: Also found a really extensive tutorial on box2D that I'm going to read up on. http://www.raywenderlich.com/606/how-to-use-box2d-for-just-collision-detection-with-cocos2d-iphone LP0 ON FIRE fucked around with this message at 20:33 on Apr 15, 2011 |
# ? Apr 15, 2011 20:12 |
|
NOG posted:So how can you have a method checked every frame? Yeah that will be every frame, cocos2d will hook into CADisplayLink if it can.
|
# ? Apr 15, 2011 21:12 |
|
Bob Morales posted:Is there any reason not to do stuff like puzzle games in just plain UIKit? I made a simple puzzle game in UIKit and it performed just fine on even the original iPhone. It had an 8x9 grid of images, with objects users could move around, and basic animations. All of the objects were simple UIImageViews.
|
# ? Apr 15, 2011 23:09 |
|
Hey Clang friends: I'm hearing about Clang LLVM 3.0, but the current version is 2.9 and I don't see any info on 3.0. Given it's an open source project, can you talk about (or point to) some info about 3.0?
|
# ? Apr 16, 2011 03:12 |
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
AlwaysWetID34 fucked around with this message at 17:33 on Jan 18, 2019 |
# ? Apr 16, 2011 18:46 |
|
Try initWithFormat: instead of initWithString:. The former works like printf, which seems to be what you want, and the latter just takes in a single string argument. Check out the documentation for details: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html
|
# ? Apr 16, 2011 19:36 |
|
Small White Dragon posted:Hey Clang friends: I haven't seen anything. You can check the Clang mailing list archive but I'm not sure that they've really discussed it beyond 100% C++'0x support. I've been curious myself about what is coming up for Objective-C but haven't heard anything.
|
# ? Apr 16, 2011 21:12 |
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
AlwaysWetID34 fucked around with this message at 17:33 on Jan 18, 2019 |
# ? Apr 16, 2011 22:24 |
|
Using Xcode 4, is there a keyboard shortcut to switch between the main editor and the assistant editor? The "Move Focus To Editor..." command would work and be only slightly annoying for requiring two keystrokes to switch, but I have to hit a different keystroke to switch to each editor, and I have to think about it every drat time and it's starting to drive me insane.
|
# ? Apr 17, 2011 01:20 |
|
I'm working on my first iPhone game and have come up against a bit of a showstopper. I need a scrabble dictionary in memory to do some very fast spellchecking, hopefully checking about 100 words vs 250,000+ words in a single frame. If I hardcode the whole thing in XCode 4 as a single massive line of code like this: wordList = [NSArray arrayWithObjects:@"aa", @"aah", @"aahed", ... @"zyzzyvas",nil]; The compiler just hangs. It doesn't crash, but it will sit there and chew on it for 30 minutes until I cancel it. In the past, I've written the same thing, both in C and in flash's actionscript without this sort of problem, so I'm just wondering if anyone can shed some light on any practical limits of XCode, the iOS GCC compiler and iOS itself, or maybe suggest a workaround to my crappy method. Also any suggestions on the best way to hold and process that amount of data in Objective C (and on an iPhone) would be good. I plan to just do a binary search on it for speed. But I have no idea how an NSString 'compare' will rate for speed and overhead against a simple C style string comparison like this: if( (char*)myWord < (char*)WordList[index] )
|
# ? Apr 17, 2011 11:04 |
|
monkey posted:I need a scrabble dictionary in memory to do some very fast spellchecking, hopefully checking about 100 words vs 250,000+ words in a single frame. First step is to use an NSSet, not an NSArray, because you don't care about order. But when you run into the same problem, check out tries, their memory-saving counterpart radix trees, and their goofy cousin dawgs. There's also plenty more where those come from, so poke around. The idea is to use a data structure whose lookups take time proportional to the length of the word you're checking, as opposed to time proportional to the number of words in your dictionary. If filling this data structure takes too long on the device, you can do it beforehand and dump it to a file, to be loaded on the device when needed. Comedy option: let ragel do the work for you.
|
# ? Apr 17, 2011 12:25 |
|
monkey posted:If I hardcode the whole thing in XCode 4 as a single massive line of code like this: Errrrgh. A 250k element NSDictionary? Try something like this instead, it explains the theory and links to other implementations, including C. By Peter Norvig, Google Wizard. Or you could link to aspell NotShadowStar fucked around with this message at 12:42 on Apr 17, 2011 |
# ? Apr 17, 2011 12:32 |
|
pokeyman posted:First step is to use an NSSet, not an NSArray, because you don't care about order. But when you run into the same problem, check out tries, their memory-saving counterpart radix trees, and their goofy cousin dawgs. There's also plenty more where those come from, so poke around. Thanks! Not the answer I was looking for, but very interesting. I found that a plain binary search was fast enough, it's more the reason I need the whole thing in RAM all the time. When I say "fast enough"... a prototype version written in flash and running on an android phone is able to parse 200+ words without a hitch at 30FPS. I'll implement it as a binary search first (already wrote that code years ago) and if it's not quick enough, I'll definitely look into setting up a DAWG. On the surface, my guesstimation is that DAWG may shave off about 30% of the operations, but take about 3 times the RAM. This is only because a lot of the strings I have to check will be 9 letters long. Are you saying NSSet containsObject is faster than a binary search in an ordered array? I'm not familiar with NSSet, but that seems pretty amazing. Anyway the answer I really needed was "Load it from an external file, you dolt" Now I'm looking into how I'm supposed to do that. Wondering whether the convenience of arrayWithContentsOfFile is worth the XML bloat, and whether I can even use fopen and fgets on iOS.
|
# ? Apr 17, 2011 15:28 |
|
Does anyone have any recommendations for a decent iOS or cross-platform vector math library to use with OpenGL? I've been rolling my own linear algebra functions, but the project I'm working on is getting larger and I'd rather use a well-tested third-party library. Most of the 3d programming I've done on PCs has been in DirectX, so I'm used to having the D3DX math functions rely on.
|
# ? Apr 17, 2011 16:24 |
|
monkey posted:I'm working on my first iPhone game and have come up against a bit of a showstopper. I need a scrabble dictionary in memory to do some very fast spellchecking, hopefully checking about 100 words vs 250,000+ words in a single frame. Stackoverflow gives a suggestion of using a form of compression (since you've only got 26 letters, no need to use a byte for each character) and cramming each of the 250k words in to a 64-bit value, ending up at 2mb. http://stackoverflow.com/questions/2276641/way-to-store-a-large-dictionary-with-low-memory-footprint-fast-lookups-on-andr
|
# ? Apr 17, 2011 18:15 |
|
^^ oh, that 5 bit compression is nice, I'll use that. I got it working... The wordlist now loads as a NSString from a CSV file, the string is split into an NSArray, the NSArray converted to a NSSet. There's a hasWord method, [dict hasWord:@"TESTING"] returns true, [dict hasWord:"FKJHDSA"] returns false Everything is good. edit: and it's fixed. monkey fucked around with this message at 20:01 on Apr 17, 2011 |
# ? Apr 17, 2011 18:44 |
|
monkey posted:and whether I can even use fopen and fgets on iOS.
|
# ? Apr 17, 2011 18:50 |
|
monkey posted:Are you saying NSSet containsObject is faster than a binary search in an ordered array? I'm not familiar with NSSet, but that seems pretty amazing. I don't know if you're familiar with big-O notation, but if you are, binary search is O(log n) with n the number of words while a hash table (NSSet) is O(1) amortized. If you're unfamiliar with big-O notation, learn it, it's useful, but the translated version of the above is binary search takes longer when you have more words, while a hash table doesn't. edit: Small White Dragon posted:Absolutely you can. http://www.youtube.com/watch?v=q73MjnazIfg#t=0m23s pokeyman fucked around with this message at 22:23 on Apr 17, 2011 |
# ? Apr 17, 2011 22:20 |
|
pokeyman posted:I don't know if you're familiar with big-O notation... Familiar enough to realise it's not O(exp n) so there's not much speed difference between 2,000 and 200,000 words. Would NSSet be practical to store nothing but long ints like in the stackoverflow link Bob Morales posted? I mean practical in terms of the memory footprint and any memory thrashing it may have, compared to just 1 static long int per word? I'm working on the other end of the search at the moment, and NSStrings are giving me a bit of grief with their handling of individual characters. I'm coming from Actionscript where "searchString+=charArray[x][y];" is valid syntax. It may turn out that converting to long ints will be a lot faster to stitch the searched words together out of a 2D array. I'll benchmark the two search methods anyway, since they're both written now.
|
# ? Apr 17, 2011 23:51 |
|
monkey posted:Familiar enough to realise it's not O(exp n) so there's not much speed difference between 2,000 and 200,000 words. Would NSSet be practical to store nothing but long ints like in the stackoverflow link Bob Morales posted? I mean practical in terms of the memory footprint and any memory thrashing it may have, compared to just 1 static long int per word? Foundation collections are a pain to use with ints because you have to keep boxing/unboxing them. I'd probably just find/write some C hash table (or use CFSet if you're really partial to Apple libraries).
|
# ? Apr 18, 2011 00:48 |
|
Beginner question: Let's say you're making a falling blocks game, using UIKit. For a 10 square by 10 square game field, would you make an array of UIImageViews, or would you just make an array of a 'block' struct/objects? code:
code:
If I used the second way, would I just use a method like drawAtPoint to draw the bitmap for the block for each cell in the gameGrid? Let's say I'd have < 20 images total, some for different colors of blocks and then maybe 'jewels' or another piece of each color. Would I just keep the UIImageViews off screen or hidden, or what in that case?
|
# ? Apr 18, 2011 03:01 |
|
Bob Morales posted:Beginner question: For UIKit I'd use UIImageView, because it's so easy and you can tap into sweet UIView animations. However if you're going to have a ton of objects on the screen moving around and you want to have accurate positional info about them you might want to use OpenGL (cocos2d is pretty great). It's more helpful for "real-time" games. (as opposed to turn-based)
|
# ? Apr 18, 2011 03:10 |
|
Bob Morales posted:Let's say you're making a falling blocks game, using UIKit. For a 10 square by 10 square game field, would you make an array of UIImageViews, or would you just make an array of a 'block' struct/objects? The difference here is in the first case you're combining a model and a view, whereas in the second you're separating the two. I'd recommend the second; I find this separation easier to do from the start than later on, and you inevitably need to do it. quote:If I used the second way, would I just use a method like drawAtPoint to draw the bitmap for the block for each cell in the gameGrid? Let's say I'd have < 20 images total, some for different colors of blocks and then maybe 'jewels' or another piece of each color. You could use a bunch of UIImageViews, or just use UIImage's -drawAtPoint: or -drawInRect:. Maybe wrap this up in a UIView subclass, so you can just tell your custom view -drawBlock:atX:y: in your view controller.
|
# ? Apr 18, 2011 03:17 |
|
Hey, how do I compile a single file with a different compiler in Xcode 4? I have one C++ file that makes use of variable-size new[]'s, and this bombs on ARMv6 devices with Clang. Unfortunately, most of the project makes use of Objective C features only available in Clang.
|
# ? Apr 18, 2011 08:17 |
|
I am in the process of writing a new iPhone app that will be heavily dependent on the API and will have a large number of API calls coming in and out. How do you guys usually structure your API client libs in an iPhone app? I thought about having a base API request object and sub-classing them for each API method, but depending on the controller that would be implementing them, that would be alot of seperate delegates to tie in to each class. Another one I saw was supplying a selector which I've seen ASIHTTPRequest use as well as ShareKit. They let you supply a "finished" selector and looks for that in the class defined as the delegate. [delegate performSelector:finishedSelector withObject:data]; Any tips/suggestions, etc? nullfox fucked around with this message at 20:33 on Apr 18, 2011 |
# ? Apr 18, 2011 19:46 |
|
WildFoxMedia posted:Any tips/suggestions, etc? I'm not sure I entirely understand your question, so apologies if this is useless. If you're targeting iOS 4.0+, have your API library take blocks as completion handlers. code:
|
# ? Apr 18, 2011 22:48 |
|
You can also just take a list of blocks. But I second the motion on blocks - it is much closer to writing "normal" code and really easy to use. Generally you can just have your API class expose the methods that take certain parameters and run onSuccess and onError blocks depending on the situation. If you have more advanced needs you can define a protocol so that you could have different underlying APIs or a simulator. The onComplete can pass any number of objects into the block when it runs. Personally I don't care for having a bunch of different Request/Response objects for each operation but some people do it that way. It just seems like a lot of boilerplate to wrap and unwrap the parameters. Just don't fall into the trap of thinking that because you didn't have to write new methods or re compile that you are doing a good thing. I've known too many people that think having an ultra-flexible interface or doing stuff in SQL stored procs are great because hey - changes without a new build! Until I remind them that those are changes that receive no testing or validation before deploying to production.... So instead of catching the bugs at compile time and re-running unit tests, they decided to let customers find the bugs in the field.
|
# ? Apr 18, 2011 23:12 |
|
Ender.uNF posted:You can also just take a list of blocks. Or maintain one. [thinger onSuccess:^(id result) { ... }] adds the block to the array of success handlers, all of which are called on the success event. Like an EventEmitter. That'd be handy to have for Foundation actually... Ender.uNF posted:Just don't fall into the trap of thinking that because you didn't have to write new methods or re compile that you are doing a good thing. I've known too many people that think having an ultra-flexible interface or doing stuff in SQL stored procs are great because hey - changes without a new build! Sounds like a case of You Ain't Gonna Need It. Don't code anything you're not using right now. Don't extract code into its own framework/project unless you're actually using it from more than one place. Don't add features you aren't using or testing constantly.
|
# ? Apr 18, 2011 23:40 |
|
pokeyman posted:Or maintain one. [thinger onSuccess:^(id result) { ... }] adds the block to the array of success handlers, all of which are called on the success event. Like an EventEmitter. That'd be handy to have for Foundation actually... Oh coming from C#, a proper event handling system with real language support would be fantastic, but they have already moved beyond next-next gen. LINQ/PLINQ is awesome and the IObservable stuff makes composing event handlers really cool (and solves the unhook problem too). But the real magic is the async stuff that is coming next. It makes closures look positively ancient by comparison. You literally write code that looks and works just like regular old synchronous code but gets turned into async calls with completion and error handlers by the compiler. C# is turning into the best parts of C, Java, dynamic languages like Python, and functional programming... But without the glacial pace, infighting, and 'sperging architecture astronauts that tend to dominate projects like GCC or Java 1.7 Not that I'm abandoning Objective-C by any means!
|
# ? Apr 19, 2011 00:11 |
|
^^ What's that toolbar or whatever called with the arrows on it? I don't see it in my books, I want it. Edit: gently caress nevermind, it's just a black toolbar. Bob Morales fucked around with this message at 03:20 on Apr 19, 2011 |
# ? Apr 19, 2011 03:18 |
|
Tapjoy's going down (maybe), if you don't know about it, it's like those "sign up for these free trial offers to get a new iPod!" http://www.tuaw.com/2011/04/19/apple-banning-pay-per-install-apps-from-the-app-store-says-tapjo/ I'm glad I avoided that bullshit, do anyone of you have any inside info about this? OHIO fucked around with this message at 16:47 on Apr 19, 2011 |
# ? Apr 19, 2011 16:44 |
|
|
# ? May 15, 2024 03:19 |
|
In Flash, you can normalize a velocity by using this: vel.normalize(speed). But in Objective C or Cocos2d, what is built in? I know of ccpNormalize(vel), but I don't understand how I can make it work like the Flash one. I guess if I knew more about normalization I'd just do the math, but is there anything built in? edit: I get it now I think according to this http://www.cocos2d-iphone.org/forum/topic/759 LP0 ON FIRE fucked around with this message at 20:34 on Apr 19, 2011 |
# ? Apr 19, 2011 19:50 |