Skip to main content
gamedev.net
🔒 Locked

manipulating array

Started by Filip Sep 5, 2003 at 4:47 AM 1 replies 700+ views
Original Post
Filip
Filip
Now that i have my 2d vector issues cleared, i just returned to my old never finished ASCII game.You see, the idea is to use an array to store characters like * and others to make objects and various blocks.I was just wondering 1. how do i change color of characters (c++)?i want to have different colored characters. 2. nested loop is useed to access array and to write something to it, or something like that to write to it?Lets imagine that every object in world has struct with coordinates of its bunch of ascii characters.I need to move an object up,down or something i need to change its adress in an array.So i think i should copy it to temp clear the main array and move ascii char for instance place up or down, right?I am wondering if anyone has an idea how to do it?I mean how to move it, efficiently as possible? or anything else:again, thanks in advance for your help!
TechnoGoth
TechnoGoth
well first you don't want to use a pointer array instead use a real one.


//set the number of objects in the world

#define SIZE 50
//creates the array that makes up your world.

MyObject world[SIZE];

//draw the world

for (int i=0; i<SIZE;i++)
{
world[i].draw()
}

//move two objects in the world.

swap(int first, int second)
{
MyObject * temp;
temp = first;
world[second]=world[first];
world[first]=temp;
delete temp;
}


Look here for the drawing information
-----------------------------------------------------
Writer, Programer, Cook, I'm a Jack of all Trades
Current Design project
Chaos Factor Design Document



[edited by - TechnoGoth on September 5, 2003 8:08:15 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.