For those of you who've been wondering...
Moderator: Forum Moderators
- Elvish_Pillager
- Posts: 8137
- Joined: May 28th, 2004, 10:21 am
- Location: Everywhere you think, nowhere you can possibly imagine.
- Contact:
For those of you who've been wondering...
...why I haven't posted in the last 24 hours it's because I've been writing a cool little computer game. It's a kind of weird top-scrolling kind of game:
You control a space ship called the "Dastard", which automatically fires a shot every 0.4 seconds. The shots go straight up. Falling from the top of the screen are "Rocks", which accelerate downwards. When a shot hits a rock, the rock and shot are destroyed and two new rocks are created where the old rock was, each with half the radius of the original. When a rock reaches the side of the screen, it bounces, and when it reaches the bottom, it vanishes. Also, there are rocket launchers which move down the screen at a constant speed, firing guided missiles, which chase you for two seconds, after which they fall and the launcher fires a new missile.
Attached is a screenshot, one version with and one without comments. (Yes, I need better graphics. The current ones are temporary, since this started out as an Objective-C exercise.)
You control a space ship called the "Dastard", which automatically fires a shot every 0.4 seconds. The shots go straight up. Falling from the top of the screen are "Rocks", which accelerate downwards. When a shot hits a rock, the rock and shot are destroyed and two new rocks are created where the old rock was, each with half the radius of the original. When a rock reaches the side of the screen, it bounces, and when it reaches the bottom, it vanishes. Also, there are rocket launchers which move down the screen at a constant speed, firing guided missiles, which chase you for two seconds, after which they fall and the launcher fires a new missile.
Attached is a screenshot, one version with and one without comments. (Yes, I need better graphics. The current ones are temporary, since this started out as an Objective-C exercise.)
- Attachments
-
- ScreenShot1-Comments.png (23.01 KiB) Viewed 6195 times
-
- ScreenShot1.png (21.4 KiB) Viewed 6176 times
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
-
- Posts: 3
- Joined: January 10th, 2005, 8:14 am
- Elvish_Pillager
- Posts: 8137
- Joined: May 28th, 2004, 10:21 am
- Location: Everywhere you think, nowhere you can possibly imagine.
- Contact:
That is a possibility. However, an appearent memory leak which I cannot seem to locate is discouraging me from progressing. Oh well, I can code some more features anyway.classic_gamer wrote:Hey. That looks fun. Are you going to release it?
What this game "really needs" right now is:
-a penalty for getting hit beyond an annoying sound, probably including a way to lose the game if it happens too much.
-a fix to the problem (suspected to be a memory leak) that causes the game to build up lag over the course of the game, decreasing the quality of the sounds until they vanish altogether, and if you are really persistent you can keep playing until the game crashes.
-a reward for shooting rocks.
My plans:
-Find and fix the ****ing problem (a low priority, because I have no idea how to proceed)
-Implement a powerup system, where a rock blowing up has a chance of releasing a powerup. (which will fly upwards at a random angle, falling with gravity like the rocks do.) Each powerup will increase a capability of the Dastard, which will be decreased (to a minimum of the default) when the Dastard is hit. (A high priorty because it's an 'improvement', as in it makes the game 'easier', which doesn't hurt testing the way being able to be killed does.)
-Implement a shield system, where whenever you are hit you lose shields, and when your shield is gone, you're dead. You will not have multiple 'lives', but the shield maximum will be high, and there will be plenty of shield-restoring powerups. I want this game to be fairly easy. (Maybe I'll implement this sometime and then comment out the code so it doesn't get in my way.)
-Implement a 'stage' system or something similar, probably to work somewhat like the way Asteroids' does. (Progressive, randomly generated stages, increasing in difficulty.)
-Implement a user-interface better than "Click to begin, CMD-Q to quit, anything else to do nothing" (obviously you can also use the controls in the game, but that's not the same kind of thing)
-Make some more types of enemies. (Two is not a good number for these kind of games, it would be good to be much higher)
So, I have quite a few things left to do. None of them are particularly hard (for me at least) (except the first...) since I created the underlying engine in a way that makes it fairly easy to implement the kind of things I want to implement. So, I have a bunch more work to do, and I could probably do it in a few more days, but unless the problem reveals itself, when (if) I first release it it may not even work to play for an extended period of time. Oh well, maybe someone who knows stuff I don't will come and tell me what's wrong at that point.
EDIT: Also, since I've kind of started discussing the development of the game, perhaps this should be moved to Game Development?
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
-
- Posts: 3
- Joined: January 10th, 2005, 8:14 am
And thus, there was Valgrind. But it's Linux only.Elvish Pillager wrote:That is a possibility. However, an appearent memory leak which I cannot seem to locate is discouraging me from progressing. Oh well, I can code some more features anyway.
Now if only you made it portable so you could run it on Linux!
With C++, Resource Acquisition Is Initialization (RAII), possibly coupled with the use of reference-counted smart pointers, makes resource leaks fairly easy to guard against.
Does anyone know if Objective-C supports a similiar mechanism?
David
Does anyone know if Objective-C supports a similiar mechanism?
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Actually, EP, if you post your source files, I can take a look at them.
With regard to dave's comment, yes, I *think* Objective-C has a similar method. We call it "retain/release" - two messages which are supported by all objects.
If you need a reference to an object, you "retain" it. If you don't need it anymore, you "release" it. Once no one is retaining it, the system deallocates it. (there is also a delayed-release method using NSAutorelease, but it's basically the same thing).
With regard to dave's comment, yes, I *think* Objective-C has a similar method. We call it "retain/release" - two messages which are supported by all objects.
If you need a reference to an object, you "retain" it. If you don't need it anymore, you "release" it. Once no one is retaining it, the system deallocates it. (there is also a delayed-release method using NSAutorelease, but it's basically the same thing).
- Elvish_Pillager
- Posts: 8137
- Joined: May 28th, 2004, 10:21 am
- Location: Everywhere you think, nowhere you can possibly imagine.
- Contact:
The sources are here.
Thing is, I release just about everything that it makes sense to. I even tried releasing most of the things it didn't make sense to, but none of that helped. I also checked whether anything else (like the number of enemies) is getting excessive, but nothing worked, so I'm basically stumped.
Also, I've made some 'progress'; I implemented the powerups, and decided they were no good, so that's one thing off my to-do list...
Thing is, I release just about everything that it makes sense to. I even tried releasing most of the things it didn't make sense to, but none of that helped. I also checked whether anything else (like the number of enemies) is getting excessive, but nothing worked, so I'm basically stumped.
Also, I've made some 'progress'; I implemented the powerups, and decided they were no good, so that's one thing off my to-do list...
- Attachments
-
- Fling sources.zip
- (13.2 KiB) Downloaded 504 times
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
- Elvish_Pillager
- Posts: 8137
- Joined: May 28th, 2004, 10:21 am
- Location: Everywhere you think, nowhere you can possibly imagine.
- Contact:
New update: I implemented shields and score. The Dastard starts with 100 shield which goes down by one every time it gets hit, and gains 1 point (of score) when its shots split a rock and 2 when it kills a Rocket Launcher. (It still doesn't have a way to die yet, and 100 shield lasts longer than the game lasts anyway.)
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
But do you have to explicitly call 'release' on the object? If so, then it's not like RAII. With RAII, the resource is automatically released when the owning object falls out of scope.Jetryl wrote: With regard to dave's comment, yes, I *think* Objective-C has a similar method. We call it "retain/release" - two messages which are supported by all objects.
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
- Elvish_Pillager
- Posts: 8137
- Joined: May 28th, 2004, 10:21 am
- Location: Everywhere you think, nowhere you can possibly imagine.
- Contact:
Another new feature: "Magnetite" is a kind of rock with an acceleration towards the Dastard proportional to its own radius and inversely proportional to the distance to the Dastard. These things are nasty, because when they hit you, they break, and the broken pieces are attracted towards you again from very close by. One magnetite hit can deal as much as 10 damage, if you're unlucky.
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
-
- Posts: 3
- Joined: January 10th, 2005, 8:14 am
Yes, you do have to explicitly call it, but this is usually called in an object's destructor. Otherwise, if something is done in a function, you just create and retain the thing at the start, and release the thing at the end.Dave wrote:But do you have to explicitly call 'release' on the object? If so, then it's not like RAII. With RAII, the resource is automatically released when the owning object falls out of scope.Jetryl wrote: With regard to dave's comment, yes, I *think* Objective-C has a similar method. We call it "retain/release" - two messages which are supported by all objects.
David
Creation is done with an "alloc" message, which automatically retains the object, and then an "init" message follows to initialize any subclasses. Typically, in the destructor one does the "release" command for any subclasses. (this is basically a lot like C++
a typical initialization message - note that "id" is the generic object type, in objective-c, typed objects are optional - this provides all the benefits of templates, and virtual functions
Code: Select all
id anObject = [[SomeClass alloc] init];
Code: Select all
- dealloc {
[companion release];
free(privateMemory);
vm_deallocate(task_self(), sharedMemory, memorySize);
[super dealloc];
}
Last edited by Jetrel on January 12th, 2005, 7:15 am, edited 1 time in total.
Possibly, but the REAL power of Objective-C lies in Apple's mind-blowing frameworks for the language.classic_gamer wrote:Does anybody know if I could build this on windows or Linux using the Objective-C gcc compiler?
They have been somewhat reconstructed by GNUStep, but it might not work, as apple has leapt ahead in technology over the past year or so.