Ejemplo n.º 1
0
/*
*	Rotates the cube down by changing the sides, and rotating them as needed.
*/
void Cube::rotateDown() {
	getBack()->xAxisFlip();
	
	Map temp = sides[0];
	sides[0] = sides[1];
	sides[1] = sides[5];
	sides[5] = sides[4];
	sides[4] = temp;

	getLeft()->rotateClockwise();
	getRight()->rotateCounterClockwise();

	getBack()->xAxisFlip();
}
Ejemplo n.º 2
0
Vector3f CameraUtility::getRight() {
	Vector3f up = getUp();
	Vector3f back = getBack();
	Vector3f right = up.cross(back);

	return right;
}
Ejemplo n.º 3
0
bool makeCSV(CWDB* pWDB)
{
	FILE* pFile;
	int c,s;
	char* str;
	fopen_s(&pFile,"items_gen.csv","w");

	if(!pFile)
		return false;

	// write the goods
	for(int i=0;i<(int)pWDB->getRecords()->size();++i)
	{
		c = (int)pWDB->getField(i,3)->uival;
		if( c != Weapon && c != Armor )
			continue;
		s = (int)pWDB->getField(i,4)->uival;
		str = pWDB->getField(i,6)->pchar;
		fprintf(pFile,"%u,%u,%u,%u,%u,%u,%u,%s\n",
			pWDB->getField(i,1)->uival, // ItemID
			pWDB->getField(i,10)->uival,	// DisplayID
			c, // ItemClass
			s, // ItemSubClass
			pWDB->getField(i,15)->uival, // Slot
			(u32)getBack(c,s), // Position on character
			pWDB->getField(i,113)->uival, // Sheath
			pWDB->getField(i,6)->pchar
		); 

		// Time to
	}

	return true;
}
Ejemplo n.º 4
0
void LinkedList::addBack(int value){
	Node* n = new Node;
	n->setValue(value);
	if(isEmpty()){
		m_front = n;
		m_size++;
		n = nullptr;
	}
	else if(m_front == getBack()){
		m_front->setNext(n);
		m_size++;
		n = nullptr;
	}
	else{
		bool notDoneLooking = true;	//for the while loop
		Node* stepper = m_front;	//this pointer will change as we comb through the list
		while(notDoneLooking){
		
			if(nullptr != stepper->getNext()){	//check the current Node's pointer value
				stepper = stepper->getNext();	//if !null, set stepper to look at the next 									Node
			}
			else{					//if stepper points to a Node that points at 										null,we are at the end, add the new 										node to the back
				notDoneLooking = false; 	//break loop
				stepper-> setNext(n);		//the last  node now looks at the new node
				m_size++;			//the new node should already be initialized 										to null
				n = nullptr;
			}
			
		}
	}
}
Ejemplo n.º 5
0
int AscFile::save(char *filename) {
	FILE *fp;

	fp = fopen(filename, "w");

	if(fp == NULL)
		return 0;

	float version = 0.1;
	fprintf(fp, "ASCII-Paint v%g\n", version);
	fprintf(fp, "%i %i\n", width, height);

	// Use the # character as a marker for the start of image data
	fputc('#', fp);

	// Write the brush data for every brush in the image
	for(int x = 0; x < width; x++) {
		for(int y = 0; y < height; y++) {
			char c = getChar(x, y);
			AscRgb f = getFore(x, y);
			AscRgb b = getBack(x, y);

			fputc(c, fp);
			fputc(f.r, fp);
			fputc(f.g, fp);
			fputc(f.b, fp);
			fputc(b.r, fp);
			fputc(b.g, fp);
			fputc(b.b, fp);
		}
	}
	fclose(fp);
	return 1;
}
Ejemplo n.º 6
0
bool LinkedList::removeBack(){
	if(isEmpty()){
		return false;
	}
	else if(m_front == getBack()){ //if there is only one element in the list, just delete it and be done.  Note that when this is the case, the last and the first item are the same Node.
		delete m_front;
		m_size--;
		m_front = nullptr;
		return true;
				
	}
	else{

		Node* previous = nullptr;	//this will point to the last non-null Node (second to last)
		bool notDoneLooking = true;	//for the while loop
		Node* stepper = m_front;	//this pointer will change as we comb through the list
		while(notDoneLooking){
		
			if(nullptr != stepper->getNext()){	//check the current Node's pointer value
				previous = stepper;		//keeps track of the second to last
				stepper = stepper->getNext();	//if !null, set stepper to look at the next 									  Node
			}
			else{					//if stepper points to a Node that points at 									  null,we are at the end
				notDoneLooking = false; 	//break loop
				previous-> setNext(nullptr);	//new last Node now points to nullptr
				delete stepper;
				stepper = nullptr;		//housekeeping
				m_size--;
			
			}
		
		}//end while
	
	}//end empty wrapper
}
Ejemplo n.º 7
0
/*
*	Rotates the cube left by changing the sides, and rotating them as needed.
*/
void Cube::rotateLeft() {

	//invert y axis of the back
	getBack()->yAxisFlip();

	Map temp = sides[0];
	sides[0] = sides[3];
	sides[3] = sides[5];
	sides[5] = sides[2];
	sides[2] = temp;

	getTop()->rotateClockwise();
	getBottom()->rotateCounterClockwise();

	//invert y axis of the back
	getBack()->yAxisFlip();
}
Ejemplo n.º 8
0
String Card::getAll() {
	String all = getQuantity()+","+getText()+","+getThumb()+","+getFront()+
			","+getBack()+","+getId()+","+getRate()+","+getValue()+","+getNote()+","+getOrientation()+",";
	for (int i = 0; i < stats.size(); i++) {
		all += stats[i]->getAll() + "$";
	}
	return all;
}
Ejemplo n.º 9
0
void CameraUtility::roll(float angleDegrees) {
	Vector3f up = getUp();
	Vector3f back = getBack();
	//Vector3f
	Matrix4 currentTransform;
	currentTransform.rotate_axis(&back[0], angleDegrees);
	currentTransform.multpoint3d(&up[0], &up[0]);

	ms_displayDevice->set_eye_up(&up[0]);
}
Ejemplo n.º 10
0
void main()
{
    Queue<int> aQueue;

    for (int i = 0; i < 5; i++)
    {
        aQueue.enqueue(i);
    }
    
    cout << getBack(aQueue) << endl;
   
    system("pause");
}
Ejemplo n.º 11
0
Archivo: ui.cpp Proyecto: wesulee/mr
std::vector<Color> Gradient::generate(const int length) {
	assert(length >= 2);
	if (!sorted) {
		std::sort(pairs.begin(), pairs.end(), GradCmp());
		sorted = true;
	}

	std::vector<Color> colors;
	colors.reserve(static_cast<std::size_t>(length));

	if (pairs.empty()) {
		grad(colors, getFront(), getBack(), length);
		colors.push_back(getBack());
		return colors;
	}

	auto it = pairs.cbegin();
	Color start = getFront();
	Color end;
	int cDist = 0;		// current distance gone
	int dist;			// passed to grad()
	float prevDist = 0;
	for (auto itEnd = pairs.cend(); it != itEnd; ++it) {
		end = (*it).second;
		dist = static_cast<int>(((*it).first - prevDist) * length);
		grad(colors, start, end, dist);
		cDist += dist;
		start = end;
		prevDist = (*it).first;
	}

	end = getBack();
	dist = length - cDist - 1;
	grad(colors, start, end, dist);
	colors.push_back(end);
	assert(static_cast<int>(colors.size()) == length);

	return colors;
}
Ejemplo n.º 12
0
void Stack<T>::print()const{
	Node<T>* temp = m_top;
	Node<T>* back = getBack();
	if(m_size==0){
		std::cout<<"\n\n\n\n\n\n\n\nStack Empty\n";
	}
	else if(temp==back){
		std::cout<<temp->getValue();
	}
	else{
		while(temp!=back){
			std::cout<<temp->getValue()<<", ";
			temp = temp->getNext();
		}
		std::cout<<temp->getValue();
	}
	std::cout<<"\n";
}
Ejemplo n.º 13
0
bool LinkedList::removeFront(){
	if(isEmpty()){
		return false;
	}
	else if(m_front == getBack()){//if there is only 1 Node (when front Node is the back Node)
		delete m_front;
		m_front = nullptr;
		m_size--;
		return true;
	}
	else{

		Node* n = m_front->getNext();		//temp pointer points to the second value
		delete m_front;				//delete the object m_fron is looking at (old front 								  node)
		m_front = n;				//m_front now looks at the new front Node
		n = nullptr;				//housekeeping
		m_size--;				
	}
	return true;
}
Ejemplo n.º 14
0
void LinkedList::printList()const{
	
	if(isEmpty()){
		std::cout<<"List empty.\n";
	}
	else if(m_front == getBack()){//if there is only one Node..
		std::cout<<m_front->getValue();
	}
	else{
		Node* temp = m_front;			//temp pointer
		while(temp->getNext()!= nullptr){		//while temp is not pointing the last Node
			
			std::cout<<temp->getValue()<<" ";	//print the value of the current node
			temp = temp->getNext();		//look at the next node

		}
		std::cout<<temp->getValue()<<"\n";	//since we are at the last entry, just display the value

	}
}
Ejemplo n.º 15
0
    //-----------------------------------------------------------------------
    BspNode* BspNode::getNextNode(const Vector3& point) const
    {

        if (mIsLeaf)
            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
                "This method is not valid on a leaf node.",
                "BspNode::getNextNode");

        Plane::Side sd = getSide(point);
        if (sd == Plane::NEGATIVE_SIDE)
        {
            //LogManager::getSingleton().logMessage("back");
            return getBack();
        }
        else
        {
            //LogManager::getSingleton().logMessage("front");
            return getFront();
        }



    }
Ejemplo n.º 16
0
GamesList::GamesList(QWidget *parent) : QWidget(parent)
{
    _gameList = new QTableWidget(0, 2);

    _gameList->setHorizontalHeaderItem(0, new QTableWidgetItem("Games"));
    _gameList->setHorizontalHeaderItem(1, new QTableWidgetItem("Players"));

    _joinButton.setText("Join");
    _refreshButton.setText("Refresh");
    _backButton.setText("Previous");

    _gridLayout.addWidget(_gameList, 0, 0);
    _gridLayout.addWidget(&_refreshButton, 0, 1, 1, 1, Qt::AlignTop);
    _gridLayout.addWidget(&_backButton, 1, 1, 1, 1, Qt::AlignTop);
    _gridLayout.addWidget(&_joinButton, 1, 0);

    setLayout(&_gridLayout);

    connect(&_refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
    connect(&_joinButton, SIGNAL(clicked()), this, SLOT(joinGame()));
    connect(&_backButton, SIGNAL(clicked()), this, SLOT(getBack()));
    connect(_gameList, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(joinGame()));
    connect(ListGameSlotSingleton::getInstance(), SIGNAL(newGame(UInt8,UInt8,QString)), this, SLOT(addGame(UInt8,UInt8,QString)));
}
Ejemplo n.º 17
0
void Camera::shiftBack(const float step) {
    cameraMatrix = glm::translate(cameraMatrix, getBack() * step);
}
Ejemplo n.º 18
0
Matrix3x4f CameraUtility::getTransform() {
	Matrix3x4f transform(getRight(), getUp(), getBack(), getPosition());

	return transform;
}
nfa* createNFA(char *regex){
	//printf("Creating NFA for |%s|\n",regex);
	int len=strlen(regex),i=0,j=0,temp;
	nfa* automata=initNFA(getStateCount(regex));
	while(i<automata->nStates && j<len){
		//printf("Innitialising state #%d\n",i);
		automata->states[i]=initQ();
		
		//printf("Reading regex at #%d\n",j);
		if(regex[j]!='['){
			//printf("Enqeueing terminal %c to state %d(line 51)\n",regex[j],i);
			enqueue(automata->states[i],regex[j]-0);
		}else{
			//printf("Found segment start\n");
			j++;
			if(regex[j]!='('){
				//printf("Enqeueing terminal %c to state %d(line 57)\n",regex[j],i);
				enqueue(automata->states[i],regex[j]-0);
			}
			j++;
			while(regex[j]!=']'){
				if(regex[j]!='(' && regex[j]!=')' && regex[j]!='-'){
					//printf("Enqeueing terminal %c to state %d(line63)\n",regex[j],i);
					enqueue(automata->states[i],regex[j]-0);
				}
				if(regex[j]=='-'){
					//printf("Found range marker\n");
					temp=getBack(automata->states[i])+1;
					while(temp!=regex[j+1]+1){
						//printf("Enqeueing terminal %c to state %d(line 70)\n",temp,i);
						enqueue(automata->states[i],temp);
						temp++;
					}
					j++;
				}
				j++;
			}
		}
		if(j<len-1 && regex[j+1]=='*' && i<automata->nStates){
			//printf("Found kleene star\n");
			automata->quants[i]=STAR;
			j++;
		}
		else if(j<len-1 && regex[j+1]=='+' && i<automata->nStates){
			//printf("Found plus\n");
			automata->quants[i]=PLUS;
			j++;
		}else if(j<len-1 && regex[j+1]=='|' && i<automata->nStates){
			//printf("Found or\n");
			automata->quants[i]=OR;
			j++;
		}
		else if(i<automata->nStates){
			//printf("No quantifiers found\n");
			automata->quants[i]=NONE;
		}
		j++;
		if(j<len){
			i++;
			//printf("Creating state #%d\n",i); 
		}
	}
	automata->nStates=i+1;
	//printf("\n\n");
	return automata;
}
Ejemplo n.º 20
0
String Card::getAll() {
	String all = getQuantity()+delim+getText()+delim+getThumb()+delim+getFront()+
			delim+getBack()+delim+getId()+delim+getRate()+delim+getValue()+delim+getNote()+delim;
	return all;
}
Ejemplo n.º 21
0
bool Scanner::scan()
{
    deleteComment();
    tokens.clear();
    int line = 1;
    bool success = true;
    index = 0;
    Types type;
    string str;
    DFAState state = START;
    char ch;

    while(1)
    {

        if (state == START)//初始状态,空格
        {
            str = "";
            ch = getNext();
            if (ch == '\0')
                break;
            if (ch == '\n')
                line++;
            state = getstate(ch);
            if (state != START && (state != DFACHAR) && (state != DFASTR))
                str += ch;
        }
        else if(state == DFANUM)
        {
            if (ch == '-')
            {
                ch = getNext();
                if (ch < '0' || ch > '9')
                {
                    state = DONE;
                    getBack();
                      state = SYM;
                }
                else
                {
                    getBack();

                }
            }
            else
            {
                bool isdouble = false;
                while(1)
                {
                    ch = getNext();
                    if (ch == '\0')
                        return false;
                    state = getstate(ch);
                    if (state != DFANUM)
                    {
                        if (ch == '.'&& !isdouble)
                        {
                            isdouble = true;
                            str += ch;
                        }
                        else
                        {
                            if (state == DFAID)
                            {
                                type = ERROR;
                                str += ch;
                                break;
                            }
                            getBack();
                            state = DONE;
                            type = NUM;
                            break;
                        }
                    }
                    else
                        str += ch;
                }
            }
        }
        else if (state == DFACHAR)
        {
            bool isstr = false;
            while(!isstr)
            {
                ch = getNext();
                if (ch != '\'')
                {
                    if (ch == '\n')
                    {
                        cout <<line<<":"<<"缺少单引号!"<< endl;
                        success = false;
                        getBack();
                        state = START;
                        break;
                    }
                    if (ch == '\0')
                    {
                        cout <<line<<":"<<"缺少单引号!"<< endl;
                        return false;
                    }
                    str+=ch;
                }
                else
                {
                    if (str.length() > 1)
                    {
                        cout <<line<<":"<<"Char长度非法!"<< endl;
                        success = false;
                        state = START;
                        break;
                    }
                    isstr = true;
                    type = STR;
                    state = DONE;
                }
            }
        }
        else if (state == DFASTR)
        {
            bool isstr = false;
            while(!isstr)
            {
                ch = getNext();
                if (ch != '\"')
                {
                    if (ch == '\n')
                    {
                        cout <<line<<":"<<"缺少双引号!"<< endl;
                        success = false;
                        getBack();
                        state = START;
                        break;
                    }
                    if (ch == '\0')
                    {
                        cout <<line<<":"<<"缺少双引号!"<< endl;
                        return false;
                    }
                    char temp = getNext();
                    if (ch == '\\' && temp == 'n')
                        str += 10;
                    else
                    {
                        getBack();
                        str+=ch;
                    }
                }
                else
                {
                    isstr = true;
                    type = STR;
                    state = DONE;
                }
            }
        }
        else if (state == DFAID)
        {
            while(1)
            {
                ch = getNext();
                if (ch == '\0')
                    return false;
                state = getstate(ch);
                if (state != DFAID && state != DFANUM || ch == '-')
                {
                    getBack();
                    state = DONE;
                    break;
                }
                else
                    str += ch;
            }
        }
        else if (state == SYM)
        {
            char temp = ch;
            ch = getNext();
            if (ch == '\0')
                return false;
            else if (ch == '=')
                str += ch;
            else if ((ch == '+' && temp == '+')||(ch == '-' && temp == '-'))
                str += ch;
            else
                getBack();
            state = DONE;
        }
        else if (state == DONE)
        {
            Token temp;
            if (type == ERROR)
            {
                cout <<line<<":"<< "非法变量!"<< endl;
                success =false;
            }
            else if (type == NUM||type == STR)
            {
                temp.type = type;
                temp.value = str;
                temp.linenode = line;
                tokens.push_back(temp);
            }
            else
            {
                temp.type = getType(str);
                if (temp.type == ERROR)
                {
                    cout <<line<<":"<< "字符无法识别!"<< endl;
                    success = false;
                }
                else
                {
                    if (temp.type == ID)
                        temp.value = str;
                    temp.linenode = line;
                    tokens.push_back(temp);
                }
            }
            state = START;
            type = ELSE;

        }
    }
    //    this->success = success;

    for (int i = 0;i < tokens.size();i++)
    {
        if (tokens[i].type == ID && i + 1 < tokens.size() && tokens[i+1].type == LMBRACKET)
        {
            tokens[i].type = ARRAY;
        }

    }
    return success;
}
Ejemplo n.º 22
0
int main(int argc, char* argv[])
{
    int i;
    ListRef A = newList();
    ListRef B = newList();
	ListRef ACopy = NULL;
	ListRef AB_Cat = NULL;
	insertBack(A, 10);
	insertBack(A, 20);
	insertBack(A, 30);
	insertBack(A, 40);
	insertBack(A, 50);
	insertBack(A, 60);
	printf("equals(A,B)		: %d\n", equals(A, B));
	insertBack(B, 10);
	insertBack(B, 20);
	insertBack(B, 30);
	insertBack(B, 40);
	insertBack(B, 50);
	insertBack(B, 60);
	AB_Cat = catList(A, B);
	printf("printLIST(AB_Cat)	: ");
	printLIST(AB_Cat);
	ACopy = copyList(A);
	printf("printLIST(A)		: ");
	printLIST(A);
	printf("printLIST(ACopy)	: ");
	printLIST(ACopy);
	printf("equals(A,ACopy)		: %d\n", equals(A, ACopy));
	printf("equals(A,B)		: %d\n", equals(A, B));
	printf("printLIST(A)		: ");
	printLIST(A);
	moveTo(A, getLength(A));
	printf("offEnd(A)		: %d\n", offEnd(A));
	moveTo(A, 3);
	insertBeforeCurrent(A, 35);
	insertAfterCurrent(A, 45);
	printf("printLIST(A)		: ");
	printLIST(A);
	printf("getCurrent(A)		: %d\n", getCurrent(A));
	movePrev(A);
	printf("getCurrent(A)		: %d\n", getCurrent(A));
	deleteCurrent(A);
	printf("printLIST(A)		: ");
	printLIST(A);
	makeEmpty(B);
	deleteFront(A);
	printf("printLIST(A)		: ");
	printLIST(A);
	printf("getLength(A)		: %d\n", getLength(A));
	printf("isEmpty(A)		: %d\n", isEmpty(A));
	makeEmpty(A);
	printf("isEmpty(A)		: %d\n", isEmpty(A));
	printf("getLength(A)		: %d\n", getLength(A));
	/* printf("printLIST(A)		: ");
	printLIST(A); */
	insertFront(B, 50);
	insertBack(B, 60);
	insertFront(B, 40);
	insertBack(B, 70);
	insertFront(B, 30);
	insertBack(B, 80);
	insertFront(B, 20);
	insertBack(B, 90);
	insertFront(B, 10);
	printf("printLIST(B)		: ");
	printLIST(B);
	printf("offEnd(B)		: %d\n", offEnd(B));
	moveTo(B, 5);
	printf("offEnd(B)		: %d\n", offEnd(B));
	printf("getCurrent(B)		: %d\n", getCurrent(B));
	deleteCurrent(B);
	printf("printLIST(B)		: ");
	printLIST(B);
	/* printf("getCurrent(B) 	: %d\n", getCurrent(B));*/
	moveTo(B, 0);
	printf("getFront(B)		: %d\n", getFront(B));
	printf("getCurrent(B)		: %d\n", getCurrent(B));
	deleteFront(B);
	printf("printLIST(B)		: ");
	printLIST(B);
	printf("getFront(B)		: %d\n", getFront(B));
	/* printf("getCurrent(B)		: %d\n", getCurrent(B)); */
	moveTo(B, (getLength(B)-1));
	printf("getCurrent(B)		: %d\n", getCurrent(B));
	printf("getBack(B)		: %d\n", getBack(B));
	deleteBack(B);
	printf("getBack(B)		: %d\n", getBack(B));
	/* printf("getCurrent(B)		: %d\n", getCurrent(B)); */
	moveTo(B, (getLength(B)-1));
	printf("getCurrent(B)		: %d\n", getCurrent(B));
	printf("getBack(B)		: %d\n", getBack(B));
	deleteBack(B);
	printf("getBack(B)		: %d\n", getBack(B));
	printf("getCurrent(B)		: %d\n", getCurrent(B)); 
	
	
	
    return(0);
}