Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Quellcode |
|
1 |
error LNK2005: "class sf::Texture TicTacToeTexture" (?TicTacToeTexture@@3VTexture@sf@@A) ist bereits in main.obj definiert. |
Quellcode |
|
1 |
error LNK1169: Mindestens ein mehrfach definiertes Symbol gefunden. |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
#ifndef SPRITE_HPP #define SPRITE_HPP #include <SFML\Graphics.hpp> #include <SFML\System.hpp> sf::Texture TicTacToeTexture; //Slot class class CSlots : public sf::Drawable, public sf::Transformable { private: int GridCode; int Player; sf::Sprite m_Slot1; sf::Sprite m_Slot2; sf::Sprite m_Slot3; sf::Sprite m_Slot4; sf::Sprite m_Slot5; sf::Sprite m_Slot6; sf::Sprite m_Slot7; sf::Sprite m_Slot8; sf::Sprite m_Slot9; virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const { states.transform *= getTransform(); states.texture = &TicTacToeTexture; target.draw(m_Slot1, states); target.draw(m_Slot2, states); target.draw(m_Slot3, states); target.draw(m_Slot4, states); target.draw(m_Slot5, states); target.draw(m_Slot6, states); target.draw(m_Slot7, states); target.draw(m_Slot8, states); target.draw(m_Slot9, states); } public: CSlots (); }; //Transmitter class class CTransmitter : public sf::Drawable, public sf::Transformable { private: sf::Sprite Transmitter; public: CTransmitter(); }; //X and O class class CXO : public sf::Drawable, public sf::Transformable { private: sf::Sprite X; sf::Sprite O; public: CXO(); }; //Collision class class CCollision : public sf::Drawable, public sf::Transformable { private: sf::FloatRect TransmitterBox; sf::FloatRect m_Slot1Box; sf::FloatRect m_Slot2Box; sf::FloatRect m_Slot3Box; sf::FloatRect m_Slot4Box; sf::FloatRect m_Slot5Box; sf::FloatRect m_Slot6Box; sf::FloatRect m_Slot7Box; sf::FloatRect m_Slot8Box; sf::FloatRect m_Slot9Box; sf::FloatRect XBox; sf::FloatRect OBox; public: void CheckCollisions (); CCollision(); }; #endif |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
#include "Sprites.hpp" using namespace std; CSlots::CSlots () { //set Player 1 ('X') Player = 1; //upper-left Slot (Slot1) m_Slot1.setTexture(TicTacToeTexture); m_Slot1.setTextureRect(sf::IntRect(0, 0, 200, 200)); m_Slot1.setPosition(0, 0); //upper Slot (Slot2) m_Slot2.setTexture(TicTacToeTexture); m_Slot2.setTextureRect(sf::IntRect(200, 0, 200, 200)); m_Slot2.setPosition(200, 0); //upper-right Slot (Slot3) m_Slot3.setTexture(TicTacToeTexture); m_Slot3.setTextureRect(sf::IntRect(400, 0, 200, 200)); m_Slot3.setPosition(400, 0); //middle-left Slot (Slot4) m_Slot4.setTexture(TicTacToeTexture); m_Slot4.setTextureRect(sf::IntRect(0, 200, 200, 200)); m_Slot4.setPosition(0, 200); //middle Slot (Slot5) m_Slot5.setTexture(TicTacToeTexture); m_Slot5.setTextureRect(sf::IntRect(200, 200, 200, 200)); m_Slot5.setPosition(200, 200); //middle-right Slot (Slot6) m_Slot6.setTexture(TicTacToeTexture); m_Slot6.setTextureRect(sf::IntRect(400, 200, 200, 200)); m_Slot6.setPosition(400, 200); //bottom-left Slot (Slot7) m_Slot7.setTexture(TicTacToeTexture); m_Slot7.setTextureRect(sf::IntRect(0, 400, 200, 200)); m_Slot7.setPosition(0, 400); //bottom Slot (Slot8) m_Slot8.setTexture(TicTacToeTexture); m_Slot8.setTextureRect(sf::IntRect(200, 400, 200, 200)); m_Slot8.setPosition(200, 400); //bottom-right Slot (Slot9) m_Slot9.setTexture(TicTacToeTexture); m_Slot9.setTextureRect(sf::IntRect(400, 400, 200, 200)); m_Slot9.setPosition(400, 400); } CTransmitter::CTransmitter() { //Collision Transmitter Transmitter.setTexture(TicTacToeTexture); Transmitter.setTextureRect(sf::IntRect(799, 799, 1, 1)); Transmitter.setColor(sf::Color(255, 255, 255, 255)); } CXO::CXO() { //Player 1 Sprite X.setTexture(TicTacToeTexture); X.setTextureRect(sf::IntRect(600, 200, 200, 200)); //Player 2 Sprite O.setTexture(TicTacToeTexture); O.setTextureRect(sf::IntRect(200, 600, 200, 200)); } /* CCollision::CCollision() { //Collision Boxes sf::FloatRect TransmitterBox = Transmitter.getGlobalBounds(); sf::FloatRect m_Slot1Box = m_Slot1.getGlobalBounds(); sf::FloatRect m_Slot2Box = m_Slot2.getGlobalBounds(); sf::FloatRect m_Slot3Box = m_Slot3.getGlobalBounds(); sf::FloatRect m_Slot4Box = m_Slot4.getGlobalBounds(); sf::FloatRect m_Slot5Box = m_Slot5.getGlobalBounds(); sf::FloatRect m_Slot6Box = m_Slot6.getGlobalBounds(); sf::FloatRect m_Slot7Box = m_Slot7.getGlobalBounds(); sf::FloatRect m_Slot8Box = m_Slot8.getGlobalBounds(); sf::FloatRect m_Slot9Box = m_Slot9.getGlobalBounds(); sf::FloatRect XBox = X.getGlobalBounds(); sf::FloatRect OBox = O.getGlobatBounds(); } void CCollision::CheckCollisions() { //TransmitterBox is in the first Slot if(TransmitterBox.intersects = m_Slot1Box) { int GridCode = 1; } //TransmitterBox is in the first Slot if(TransmitterBox.intersects = m_Slot2Box) { int GridCode = 2; } //TransmitterBox is in the first Slot if(TransmitterBox.intersects = m_Slot3Box) { int GridCode = 3; } //TransmitterBox is in the first Slot if(TransmitterBox.intersects = m_Slot4Box) { int GridCode = 4; } //TransmitterBox is in the first Slot if(TransmitterBox.intersects = m_Slot5Box) { int GridCode = 5; } //TransmitterBox is in the first Slot if(TransmitterBox.intersects = m_Slot6Box) { int GridCode = 6; } //TransmitterBox is in the first Slot if(TransmitterBox.intersects = m_Slot7Box) { int GridCode = 7; } //TransmitterBox is in the first Slot if(TransmitterBox.intersects = m_Slot8Box) { int GridCode = 8; } //TransmitterBox is in the first Slot if(TransmitterBox.intersects = m_Slot9Box) { int GridCode = 9; } } */ |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include "Sprites.hpp" using namespace std; //First project: TicTacToe Project //Create Window int main() { sf::RenderWindow MainWindow(sf::VideoMode(600, 700), "TicTacToe", sf::Style::Default); while (MainWindow.isOpen()) { sf::Event event; while (MainWindow.pollEvent(event)) { if (event.type == sf::Event::Closed) { printf("You clicked the 'Close' Button.\n"); MainWindow.close(); } if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) { } } MainWindow.clear(sf::Color(255,255,255)); MainWindow.display(); } return 0; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 |
//A.hpp #pragma once class A{}; A a; //A.cpp #include "A.hpp" //B.cpp #include "A.hpp" |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Checkmateing« (16.04.2014, 17:18)
Ich frage immer erst im Forum, wenn ich wirklich ohne Erfolg hartnäckig gegoogled habe.Zitat
Zitat von Checkmateing:
Außerdem hilft Google auch super bei so Zeug, einfach die Fehlermeldung googlen, da gibts oft sehr viele Fragen mit super Antworten auf Seiten wie spieleprogrammierer, cplusplus oder stackoverflow. Das soll dich nicht davon abhalten hier nachzufragen, aber vorweg schon mal zu forschen bringt mehr Glücksgefühle, weils ja doch noch von einem selbst und nicht von so einem Typen aus'm Forum kam.
Werbeanzeige