Tag Info

Hot answers tagged

15

There are no real pros or cons here, at least none that should force a programmer comfortable in one language to have to use the other. Performance shouldn't be an issue. It's unlikely that you'd write any heavy lifting with lots of messaging in the inner loops if you're a good Obj-C programmer, which means you'll really be writing those inner loops in C. ...


13

Some objective C has to be written for iPhone apps. That being said, you can write a pretty thin layer of obj-c and then do all you game code in C or C++. On android look up the NDK. I don't have any experience with it, but it promises to be a native sdk so you should be able to write most things in C or C++. That being said, you're artificially limiting ...


9

I want to learn how to dev games, and while I know in most cases the answer to this would be through C++ (at least, I would think), Actually, while C++ is an important language for anyone aspiring to enter the field professional, it is by no means the language you have to learn to make games and, in fact, makes for a rather poor first language ...


9

There's a very easy solution for that particular example. I'm assuming your arbitrary shape is just a series of points. Draw a ray from each of your objects in any direction. If the number of times it intersects a line segment on your shape is even (including zero), you are outside of the shape. If the number of times you intersect is odd, you are inside ...


8

Am I hurting myself by learning C++ before... No, C++ is a good way to learn about all the basics of programming, including Object Oriented programming, and memory management which might be handled for you in other languages. There's got to be a reason the university requires C++ It is an industry standard across the world. It is quite portable as there ...


8

You could go for a linked list, as others suggested. But basically, a snake is just a FIFO stack (sometimes called a queue) of grid coordinates: When the snake grows one bit, you just push an element on top of the stack When it moves one square, you push an element on top and pop an element off the bottom For an implementation of a queue in Objective-C, ...


8

You could think of individual places as "rooms" with "doors" connecting them: To implement this, you could create a struct Room to hold a room, with fields for a set of items currently in it and what directions its exits lie in. Then simply keep an array of all rooms and have a pointer to the one the player is currently in. There are ways of getting ...


7

Here is the method I used in my games. First, every object that needs to be persisted must implement the NSCoding protocol. You want to only store your model data and nothing specific to the current process. This means that you can't persist pointers or any resource ids that the OS gives you at runtime. For the pointers you can fix this easily by just ...


7

From my perspective, Objective-C is mainly used to develop for OS X and iOS. And even there, a lot of people tend to use C++ because of portability. Looking at a language comparison over at Ohloh, I can't really see much of a trend that Objective-C will replace C++ in the near future. Also have a look at this question (Objective-C or C++ for iOS?). I ...


7

Xcode can indeed be used to create games. You can do anything a Mac/iOS device is capable of by programming in Xcode. I think you should focus on what part of the project you want to focus on. As you state you are a brand new Objective-C programmer (welcome). In my opinion it would be quite a mouth full to try and just into Objective-C programming whilst ...


7

From the image you posted it looks like the only thing you did wrong was the order in which you applied the scale and rotation to your transformation. I don't have any experience with Cocos2D but I just mocked it up in XNA and here are the results: And here's the transformation matrix I used in XNA. See if you can find any correlation to your code: ...


7

It is possible to approximate a solution to this problem for most parametric trajectories. The idea is the following: if you zoom deep enough on a curve, you cannot tell the curve itself from its tangent at that point. By making this assumption, there is no need to precompute anything more than two vectors (three for cubic Bezier curves, etc.). So for a ...


7

You're not hurting yourself because you're doing what is required by your school. Learning to program is only partially about learning the syntax of a specific language (and it's a small part!). Right now you're learning to think logically and like a programmer. Don't worry about learning things you don't need, because it's all useful in some way.


6

There's an article on GDNet about walls and shadows in 2D; the technique can be applied to visibility determination as well. Additionally there this old-school post on 2D visibility, this post on StackOverflow and a variety of other resources online you can find via Google. Once you have a logical understanding of the visibility region for an agent in your ...


6

@Gajet's answer is impossible to follow (so I'm not even convinced it will work), and what I think @The Communist Duck meant his solution to be... block_y = ground_y + random() % (previousBlock_y + playerJumpHeight) ...will be heavily biased towards creating blocks with y-values centered around ground_y + playerJumpHeight. The easiest way to produce more ...


6

I've been writing a game for quite a while in c++ for Android. I have to touch the java code once every few weeks, but for the most part I modified one of the sample apps that comes with the NDK and have written c++ otherwise. I've had to do a bit of JNI work as well, which is never fun. However, I have many years of java experience, so having to write java ...


6

If you'd like to learn Objective-C, I suggest you have a look at cocos2d. It's an open-source 2d engine (written in Objective-C) that allows you to write games for iOS or Mac OS using XCode. It's not as easy to create games with as with a package like Unity, but there are lots of tutorials (and even books) for cocos2d to be found. A good place to start ...


6

The flick gesture is managed in two separate step: detection and conseguent dynamics. Flick Check The first one is the toughest. Basically you have to collect points in time and space when the touch starts as the touch moves. When the touch ends you have to look to what you gathered to see if there were a Flick. A simple flick check can be done by looking ...


6

The "worth" of something can only be determined by you. For some people it isn't worth porting to android for the amount of time spent vs. sales. That being said there's no reason to just use C++ for everything. Sure, the interfaces for certain things is C or Objective-C, but you can call both of those easily from C++.


5

Absolutely! XCode is the standard programming IDE for the Mac and iOS. So if your goal is making a game for iOS, you will probably be using XCode along with a few other helping technologies of your choice (e.g. OpenGL ES 2.0). But since you mentioned game engines I'd also recommend you to use one, since they'll save you a lot of time and effort: If you ...


5

If you can detect the user tapping on the screen, and know how to draw a simple textured 'quad' (two textured triangles or a triangle strip/fan) then the simplest button is just a combination of the two. Draw a quad on the screen, texture it with your button's image, then do a simple bounding box test to see if the user has tapped inside it. Be careful ...


5

Since you have pre-made break patterns. All you really need to do is collect a sub-image for each one to show. This would likely be easiest to do with a rectangle for each shape. The rectangle should encompass the entire shape. Now break the image up into these rectangles. There will be overlap. Now apply an alpha mask to each rectangle to hide everything ...


5

Looking at the art assets in your github I think I know what the problem is. What you need is alpha blending. Save your sprites with an alpha channel (or convert the background to zero alpha when loading the textures). Set up blend function like this: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); That tells OpenGL to blend (mix) the pixel data ...


5

On iOS there are two different units of measurement. Points and Pixels. On older devices a point is equal to a pixel. On new devices, there are two pixels for each point, both vertically and horizontally (so totally 4 pixels per point). An iPhone 3 has 480x320 pixels and 480x320 points. Whereas an iPhone 4 has 960x640 pixels and 480x320 points! The important ...


5

Plugins for Unity can be written using Objective C; refer to this page: http://docs.unity3d.com/Documentation/Manual/PluginsForIOS.html However I wouldn't assume that a code library of thousands of lines that wasn't designed to be used as a Unity plugin will work as a Unity plugin. It's all free so you could download Unity, fire up the demo project, and ...


4

The fundamental thing you need to do is just have code on one side that knows how to serialize data, and code on the other that knows how to deserialize. So, for variable length strings, just send the length first: n = strlen(playerid) + 1; // for NULL terminator sendto(server_sock,&n,sizeof(n),0,0,0); sendto(server_sock,playerid,n,0,0,0); and ...


4

As @slf commented any C/C++ code can be compiled for iOS devices. so you can use any of these libraries: dlib is a library which has many useful tools including machine learning. MicroPather is a path finder and A* solver (astar or a-star) written in platform independent C++ that can be easily integrated into existing code. Here is a list of some AI ...


4

There are no performance issues with Obj-C over C++. Both are compiled code, and recall that Obj-C is a superset of C, and Obj-C++ is a superset of C++, which is great when you want to mix Obj-C and C++ in the same program (easy to do and XCode has nice support for the C++ side). All language combinations support OpenGL, so any serious graphics work is ...


4

Generate a random y value between a ground y value g and a max height m. m is simply g+character jump height. I don't know how Obj-C's random works, but usually you'll want something like: block_y = (random() % m) + g;


4

Every CCNode has a children property, which is a CCArray, containing all children. Since CCLayer is a subclass of CCNode, you can get the number of children added to the layer using: [[layer children] count] Update: If you're not checking that sprite count very frequently, you can simply iterate through the children array and count the number of children ...



Only top voted, non community-wiki answers of a minimum length are eligible