Thread: Linking images to variables

  1. #1
    Unregistered
    Guest

    Question Linking images to variables

    Hey everyone hopefully someone can help me out here... basicly I'm trying to make a tilebased RPG where its all based on an array. What I want to be able to do is fill the array with letters and link every different letter to a seperate image. For example


    "my array"

    A B A C
    B B A C
    B A A C
    B A A C

    where B could be the picture of a path
    where C could be the picture of a mountian
    where A could be the picture of water

    I'm pretty stumped as to how I should do this... I've never loaded an image into a program using C++ before and I can't seem to find any tutorials telling me how to (btw this is to be run in DOS not windows). Besides even if I could figure out how to load images I dont thinK I'd be able to figure out how to link them to a variable. So any helpful links, tips or code snippets you guys could supply me with would be very helpful.

    Thx in advance!

  2. #2
    Registered User kitten's Avatar
    Join Date
    Aug 2001
    Posts
    109
    Using draphics is a bit complicated in C++. There is a source code for using bitmap in FAQ. You might wan't to make your game ASCII-based first.

    However, creating an array:
    char MapArray[100][100];

    Using it:
    MapArray[4][3] = 'c';
    Making error is human, but for messing things thoroughly it takes a computer

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    you have a couple of options.....

    you can use inheritance and virtual funtions for a polymorphic solution.
    or
    use a switch statement with a different case for every map key.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    Registered User kitten's Avatar
    Join Date
    Aug 2001
    Posts
    109
    you can use inheritance and virtual funtions for a polymorphic solution.
    or
    use a switch statement with a different case for every map key.
    If he's asking how to create a 2D array, do you really think he wants to implement inheritance and polymorphism in nearest weeks
    Making error is human, but for messing things thoroughly it takes a computer

  5. #5
    Unregistered
    Guest
    No I have already made the array I just need to link each letter to a dfifferent image.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 09-30-2008, 02:12 AM
  2. esbo's data sharing example
    By esbo in forum C Programming
    Replies: 49
    Last Post: 01-08-2008, 11:07 PM
  3. Creating local variables in a program?
    By fl0at in forum C Programming
    Replies: 5
    Last Post: 01-04-2008, 07:34 PM
  4. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  5. static variables
    By Luigi in forum C++ Programming
    Replies: 4
    Last Post: 04-24-2003, 07:13 PM