Topic:   The iPhone Project   (Read 395211 times)


0 Members and 6 Guests are viewing this topic.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #240 on: December 12, 2009, 10:28:33 AM »
 :o I'm completely surprised...
I had a bit of time this morning so I decided to see if I could overhaul my loading code to add customization and make it easier to work with. You gotta realize, the loading map/npc/tile code is the largest(and most complex) chunk of code in the iPhone game. To overhaul something of that magnitude it'd be like taking a wrecking ball to the bottom of a sky scraper. I decided to give it a shot.
The sky scraper fell hard and it looked ugly for a moment but somehow the broken pieces of the code fell exactly into the right places.
Code: Overhauled
Npc Talk/Battle System/Event System: Ready to be implemented
After next week it's going to be fast and easy. Won't have to worry about editing text files or trying to decipher complex code. The overhaul just about destroyed every piece of complexity. :)


-Gandolf

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: The iPhone Project
« Reply #241 on: December 12, 2009, 10:49:09 AM »
yay, so then we can get to the easy fun part?
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #242 on: December 12, 2009, 11:01:41 AM »
Yeah. I estimate it'll take me a few hours to stick in all these systems then the fun begins. I have finals all next week and the monday after. Tuesday a week after next, if nothing pops up... be ready.


-Gandolf
P.S. Maybe at Christmas I'll get a developer license. Then it'll be all ready to play on the iPhone and we can stick it on the app store.
« Last Edit: December 12, 2009, 11:06:38 AM by Gandolf »

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #243 on: December 21, 2009, 11:59:56 PM »
Finals are over. :)
Yes, now I have time to write the event, talk, and a more advanced battle system.
Currently SamBaylus an iPhone developer/friend showed me these awesome tutorials on 71squared.com and also this book on iPhone programming with OpenGL, OpenAL, and networking.
I'm getting the book "Beginning iPhone Game Development" for Christmas. :D This will give me the ability to not just scrap things I learned from Google together but make something professional.
Also I'm on the second tutorial on OpenGL development. It's crazy easy so far and will become very handy in the future. I don't think I'll implement it into the RPG as all that power under the hood is unneeded at the moment. Though I could whip it together if you guys really wanted.
I'm hoping to exponentially increase my rate of skill advancement. In the next game after this RPG I plan on using all I've learned. Yes, even OpenGL, OpenAL, and Networking. That game will be online and have amazing graphics with sound. Possibly 3D if we want to go all out.


-Gandolf
P.S. Have an elephant present food party day tomorrow. Should get a lot done besides that. Stay tuned.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #244 on: December 22, 2009, 08:39:15 PM »
Check out this monster:
Code: [Select]
} else //Move towards target
{
CGPoint targetPosition;
BOOL nextToTarget = NO;
if (npcToProcess.target == -2) {
targetPosition = playerData.playerTilePos;
} else if (npcToProcess.target >= 0) {
NpcData* targetNpc = [allNpcs objectAtIndex:npcToProcess.target];
targetPosition = targetNpc.position;}
int vertOrHorz = arc4random() % 2;
int moveDirection = 0;
BOOL npcMoved = YES;
if (abs(npcTilePosition.x - targetPosition.x) <= 1 && abs(npcTilePosition.y - targetPosition.y) <= 1 && !(abs(npcTilePosition.x - targetPosition.x) == 1 && abs(npcTilePosition.y - targetPosition.y) == 1)) {
vertOrHorz = 2;
nextToTarget = YES;
} else
if (npcTilePosition.x == targetPosition.x) {vertOrHorz = 0;} else
if (npcTilePosition.y == targetPosition.y) {vertOrHorz = 1;}
if (vertOrHorz == 0) { //Vertical
if (npcTilePosition.y < targetPosition.y) {moveDirection = 1;} else {moveDirection = -1;}
if (npcTilePosition.y + moveDirection >= 0 && npcTilePosition.y + moveDirection < [[tiles objectAtIndex:0] count]) {
TileData *tileToGo = [[tiles objectAtIndex:npcTilePosition.x] objectAtIndex:npcTilePosition.y + moveDirection];
if (tileToGo.npcOn==0 && tileToGo.blocked==0   && (playerData.playerTilePos.x != npcTilePosition.x || playerData.playerTilePos.y != npcTilePosition.y + moveDirection)) {
npcTilePosition.y += moveDirection;
npcTile.npcOn = 0;
tileToGo.npcOn = 1;
} else {npcMoved = NO; vertOrHorz = 1;}
}
} else if (vertOrHorz == 1) { //Horizontal
if (npcTilePosition.x < targetPosition.x) {moveDirection = 1;} else {moveDirection = -1;}
if (npcTilePosition.x + moveDirection >= 0 && npcTilePosition.x + moveDirection < [tiles count]) {
TileData *tileToGo = [[tiles objectAtIndex:npcTilePosition.x + moveDirection] objectAtIndex:npcTilePosition.y];
if (tileToGo.npcOn==0 && tileToGo.blocked==0  && (playerData.playerTilePos.x != npcTilePosition.x + moveDirection || playerData.playerTilePos.y != npcTilePosition.y)) {
npcTilePosition.x += moveDirection;
npcTile.npcOn = 0;
tileToGo.npcOn = 1;
} else {npcMoved = NO; vertOrHorz = 0;}
}
}
if (npcMoved == NO) {//Move randomly cause can't move
moveDirection = arc4random() % 2;
if (moveDirection == 0) {moveDirection = -1;}
if (vertOrHorz == 0) { //Vertical
if (npcTilePosition.y + moveDirection >= 0 && npcTilePosition.y + moveDirection < [[tiles objectAtIndex:0] count]) {
TileData *tileToGo = [[tiles objectAtIndex:npcTilePosition.x] objectAtIndex:npcTilePosition.y + moveDirection];
if (tileToGo.npcOn==0 && tileToGo.blocked==0  && (playerData.playerTilePos.x != npcTilePosition.x || playerData.playerTilePos.y != npcTilePosition.y + moveDirection)) {
npcTilePosition.y += moveDirection;
npcTile.npcOn = 0;
tileToGo.npcOn = 1;
}
}
} else { //Horizontal
if (npcTilePosition.x + moveDirection >= 0 && npcTilePosition.x + moveDirection < [tiles count]) {
TileData *tileToGo = [[tiles objectAtIndex:npcTilePosition.x + moveDirection] objectAtIndex:npcTilePosition.y];
if (tileToGo.npcOn==0 && tileToGo.blocked==0 && (playerData.playerTilePos.x != npcTilePosition.x + moveDirection || playerData.playerTilePos.y != npcTilePosition.y)) {
npcTilePosition.x += moveDirection;
npcTile.npcOn = 0;
tileToGo.npcOn = 1;
}
}
}
}
if (nextToTarget) {
if (npcToProcess.aggressive == 1) {//INITIATE BATTLE SEQUENCE!! ATTACK! ATTACK!
[self npcAttack:npcToProcess currentMapTiles:tiles allNpcs:allNpcs];
}
}
}
Yeah, this is one of my creations. A very large horror. The whole purpose of this chunk of code is just to move the Npc towards it's target. So I'll be killing this beast and making a beauty in it's place. (Hopefully one that's at least a little bit more readable and a little less lines)


-Gandolf

WarHampster


  • GMG Extraordinaire

  • ***


  • Posts: 1501

  • The People's Moderator
    • Arcade of the Absurd
Re: The iPhone Project
« Reply #245 on: December 22, 2009, 10:15:31 PM »
Good god. COMMENT YOUR CODE.

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: The iPhone Project
« Reply #246 on: December 22, 2009, 10:37:37 PM »
All I saw in that code was "tileToGo" and I thought of this.

« Last Edit: December 22, 2009, 10:37:59 PM by Gnome_Again »
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #247 on: December 23, 2009, 11:05:57 AM »
Quote
Good god. COMMENT YOUR CODE.
Yeah... I think you may be on to something.

Quote
All I saw in that code was "tileToGo" and I thought of this.
:)

Update. I've erased the whole tracking system and re-created it. I call it, Tracking System B2.
http://web.mac.com/avisaria/TrackingSystemB2.swf
So far I haven't set up blocks so the Npcs can walk on any tile, including the player's. As you can see in the video, the two human npcs on the plain grass map are set to movement style #2 and no aggression. Here's the movement chart:
Movement Style #1: Random movement
Movement Style #2: Target either player or another npc on the screen. If can't then move randomly.
Movement Style #3: Only target the player on the screen. If can't, move randomly.
The blobs and all 3 humans are set to #2. The blob is the only aggressive one. So in the video the two humans follow each other. Then when I go to the pond map, the blob targets the human and the human targets the blob. The blob is set to aggressive and kills the human then targets the player which it then attacks me. When I close and reopen the game, one human decides to set me as the target and the other human follows that human. Put in more humans and you can have a conga line.
Very easy to understand, very little code, and I can add more movement styles if needed. Now all I have to do is add in the proper blocks and such, then maybe up the smartness level to get npcs around barriers to their target.

Finished: Tracking: Stalker Mode for Npcs to follow the Player and other Npcs
Finished: Battle: Npc Vs. Player and Npc Vs. Npc

Todo:
- Event system: If this happens, then do that.
- Finish battle system: Put the movement restrictions back up and have the player able to attack when colliding with bad guy. Also make nice red text of damage hit appear when hitting each other.
- Make death routine so stuff happens when an npc or player reaches 0 hp.
- Make items/inventory. This is where I'm a bit iffy. Just 4 types of items? Potion, Weapon, Armor, and Trinket? Npcs can drop them? To pick up you step on it and a menu box appears asking to pick up? Can you only pick up weapons, armors, and trinkets that are more powerful than what you're currently wearing? Can you carry more than one of each? Can you sell any? What happens to your old armor if you pick a new armor?
- Talk routine. Pause gameplay, a transparent black bevelled edged box appears on screen with the npc's sprite in the top left corner with the Npc's name centered at the top with what he/she is saying right below that. Then below what they say, is options to choose conversations or click anywhere else and it stops talking/closes the talk window.

Answers to my questions, comments, questions of your own, hate mail?


-Gandolf
P.S. I also left room in the battle system for ranged attacks.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #248 on: December 23, 2009, 06:32:59 PM »
Alright, tracking system is finished. Took a bit longer then expected but now I gotta say that the new system looks sleek and easier to read. It contains all the same features as the old system but now has the ability to allow Npcs to follow other Npcs as well as the player. Also if wanted, I could make Npcs follow a point on the map or an object that isn't the player or an Npc.
The two blobs do look kinda cool when fighting each other.

Next assignment:
Put life meter below sprites of npcs and player (only if damaged?), also allow player to attack npc by colliding with bad guy. Show amount of damage taken by hit by red text floating from middle of player to top and disappearing. Also make death routine for npcs and player.
EDIT: Bugs, headaches, tiredness, crawling progress...


-Gandolf
P.S. I think I'll forget about the event system as it would probably be unneeded with everything being hardcoded instead of text files. I can add it back in later if needed.
« Last Edit: December 24, 2009, 04:00:10 AM by Gandolf »

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #249 on: December 26, 2009, 10:14:02 AM »
You guys have probably seen the little preview present in the Merry Christmas topic so...

I'd like to go to the next step. Currently:
Tracking System: Done
Battle System: Done
Event System: Done
Talk System: Done - May be revised - Discuss
Inventory System: Partially - Discuss

For the talking system we have to decided if we want to save each talk window as pngs or just have one blank window and have the game draw on it. Pngs would definitely be easier for me and give much better customizability options but would probably make the size bigger. This could be bad depending on how many of these we would need.

For the inventory system I want to clarify. Only 4 types of items? Weapon, armor, trinket, and potion? The player can only hold one of each type of equip-able item and infinite potions? If so then this will be very easy to implement.
Also, before I can successfully present this to you guys I'll need a few inventory sprites. Just for demonstration purposes like a pile of gold, sword, shield, potion, and maybe a necklace. We can figure out different items later after I get these things sorted out.


-Gandolf

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: The iPhone Project
« Reply #250 on: December 26, 2009, 12:07:10 PM »
Quote
You guys have probably seen the little preview present in the Merry Christmas topic so...

none of your videos work for me.
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #251 on: December 26, 2009, 01:08:44 PM »
Oh...  not even the flash/jing videos?
Right click, download this and try to open it once downloaded:
Latest Sneak Peak Video

-Gandolf

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #252 on: December 27, 2009, 05:31:53 PM »
Any other guys have issues opening some files I post? I think it may be due to me using my .mac account and that it may not be usable in different parts of the world.


-Gandolf

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: The iPhone Project
« Reply #253 on: December 27, 2009, 06:43:07 PM »
I'm fine with the ones in your post, but the links are were I can't open.
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #254 on: December 27, 2009, 07:38:48 PM »
Strange. So you can watch the jing videos but not .mov files? I couldn't embed this latest video in my post as it isn't flash.


-Gandolf