What now?

Member
Posts: 102
Joined: 2005.01
Post: #1
So far all i have made is a board game that stores piece location in an array board[8][10]

what should i try to make now? somthing that isn't a board game, id like to try something with movment.

oh yea, all i know is cocoa.
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #2
make a chess AI. Its pretty challenging but should not tale more than 400 lines of code for a recursive brute force point algorithm.

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Moderator
Posts: 675
Joined: 2002.04
Post: #3
I'd assume that you're looking to build on the abilities you've gained developing the board game, so why not try something with a foundation in arrays, a Pac Man or Rogue-alike maze/dungeon crawler?

Mark Bishop
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #4
Problem is i dont have the knowledge to do any of thatSad I have no idea how to detect colisions, get keydown events, or contol the speed of a moving character. pretty much i know how to draw an image to an NSRect. thats about it. I guess id have to use timers to control speed? Thats the extent of my knowledge. Its very annoying not knowing very much Mad Mad Mad Mad
Quote this message in a reply
Moderator
Posts: 675
Joined: 2002.04
Post: #5
Well, a Rogue-alike (search for it, there's plenty of clones online) game is typically text-based (not a text adventure), and only runs through the event loop in response to the player pressing a key, and collision detection is limited to checking if a position on the map (which could easily be implemented as a 2D array) is occupied.

Otherwise, I'd suggest you learn a API more suited to games like [evangalist]SDL[/evangalist].

Mark Bishop
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #6
I tryed to learn SDL about 3 months ago, i failed because the only things i could find were a mailing list about things way more dificult to understand than i was ready for. And 3 tutorials from 3DCone or some place like that, but i didnt understand bliting at all, so when i learned how to draw to a rect in cocoa i decided to stay with that because it seemed a ton easier.

do you know of a peticularly good source/s for learning it?
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #7
libsdl.org
click on tutorials
google "SDL tutorials"
etc, etc.

It's not magic, it's Ruby.
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #8
why doesn't this work?

NSRect tileArray[7][7];

and if it did would this work?

Code:
//setting locations of tiles
    int locationX, locationY = 0;
    int x, y;
    for (x=0;x<48;x++)    {
        for (y=0;y<48;y++)    {
            tileArray[x][y] = NSMakeRect(locationX, locationY, 32, 32);
            locationX += 32;
            if (x == 6 || x == 13 || x == 20 || x == 27 || x == 34 ||x == 41 || x == 48)    {
                locationY += 32;
                locationX = 0;
            }
        }    
    }
}
Quote this message in a reply
Member
Posts: 40
Joined: 2004.12
Post: #9
In your method you are trying to access memory at locations bigger than your array memory is allocated. Try shortening your for loops to max out at "6" instead of "48".

HTH.

Jericho
Quote this message in a reply
Member
Posts: 102
Joined: 2005.01
Post: #10
Ok real question:

I am going to try to make the rouge clone that you suggested.

to test the arrays i am going to fill the 7x7 board with the "gold" image

here is my header

Code:
#import <Cocoa/Cocoa.h>

enum {WALL, ENEMY, HERO, GROUND, GOLD};

@interface dungeonView : NSView
{
    int board[7][7];
    NSRect tileArray[7][7];
    
    NSImage *goldImage;
}
@end



and here is the section that loads GOLD into every space in board

Code:
int x, y;
    for (x = 0 ; x < 7 ; x++)    {
        for (y = 0 ; y < 7 ; y++)    {
            board[x][y] = GOLD;
        }
    }


im pretty sure that works

here is the part that places the rects around the screen im pretty sure that doesnt work

what i want is the bottom left to be tileArray[0][0] and a column to the left to be tileArray[0][1]; one row up will be tileArray[1][1].

Code:
    int xpos, ypos = 0;
    for (x = 0 ; x < 7 ; x++)    {
        for (y = 0 ; y < 7 ; y++)    {
            tileArray[x][y] = NSMakeRect(xpos , ypos, 32, 32);
            xpos += 32;
            if (x == 6)    {
                ypos += 32;
                xpos = 0;
            }
        }
    }
}



now here is the drawing part in the drawRect method

Code:
- (void)drawRect:(NSRect)rect
{
    NSRect modal;
    modal.origin = NSZeroPoint;
    int x, y;
    for (x = 0 ; x < 7 ; x++)    {
        for (y = 0 ; y < 7 ; y++)    {
            switch (board[x][y])    {
                case GOLD:
                    [NSBezierPath strokeRect:tileArray[x][y]];
                    modal.size = [goldImage size];
                    [goldImage drawInRect:tileArray[x][y] fromRect:modal operation:NSCompositeSourceOver fraction:1];
                    break;
            }
        }
    }
}


it gets this werid column on the left side of the view with 6 drawn gold squares, not starting in the bottom left

what should my loop look like?
Quote this message in a reply
Post Reply