<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[C++ Ascii Game - Weiss nicht mehr weiter...]]></title><description><![CDATA[<p>Hi an all hätte da ne frage wie könnte ich es am besten lösen einen &quot;NPC&quot; in mein<br />
Game einzubauen?<br />
Bin derzeit die ganze zeit nur auf fehler gestossen und weiss nicht wie ich das am besten machen sollte.</p>
<p>Main.cpp:</p>
<pre><code>#include &lt;Windows.h&gt;
#include &quot;include/Map.h&quot;
#include &quot;include/Player.h&quot;
#include &quot;include/Graphics.h&quot;
#include &quot;include/GetKeystrokes.h&quot;
#include &quot;include/Fiend.h&quot;

Graphics graphics;
Player player;
Map map;
Fiend fiend;
GetKeystrokes input;
bool quit = false;
bool first = false;
bool redraw = true;

void Update()
{
  if(input.IsKeyPressed(VK_ESCAPE))
    quit = true;

  if(input.IsKeyPressed(VK_RIGHT))
  {
    if(!map.IsColliding(player.GetY(), player.GetX() + 1))
    {
      player.MoveRight();
    }
    redraw = true;
  }

  if(input.IsKeyPressed(VK_LEFT))
  {
    if(!map.IsColliding(player.GetY(), player.GetX() - 1))
    {
      player.MoveLeft();
    }
    redraw = true;
  }  

  if(input.IsKeyPressed(VK_UP))
  {
    if(!map.IsColliding(player.GetY() - 1, player.GetX()))
    {
      player.MoveUp();
    }
    redraw = true;
  }  

  if(input.IsKeyPressed(VK_DOWN))
  {
    if(!map.IsColliding(player.GetY() + 1, player.GetX()))
    {
      player.MoveDown();
    }
    redraw = true;
  }   
}

void Render()
{
  graphics.ClearScreen();

  map.Render(graphics);

  player.Render(graphics);

  fiend.Spawnfiend(graphics);
}

void main()
{
  graphics.Initialize(24, 79, L&quot;ASCII GAME&quot;);

  map.Load(&quot;.\\data\\maps\\map00.txt&quot;);

  player.Initialize(35,20);

  fiend.Spawnposition(31,70);

  while(!quit)
  {
    Update();

    if(redraw)
    {
      Render();

      redraw = false;
    }    
  }
}
</code></pre>
<p>Graphics.cpp:</p>
<pre><code>#include &quot;include/Graphics.h&quot;

void Graphics::Initialize(short height, short width, wchar_t* title)
{
  handle = GetStdHandle(STD_OUTPUT_HANDLE);

  HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
  SMALL_RECT size;
  COORD b_size;

  size.Left = 0;
  size.Top = 0;
  size.Right = width;
  size.Bottom = height;
  b_size.X = width+1;
  b_size.Y = height+1;

  SetConsoleWindowInfo(hCon, true, &amp;size);
  SetConsoleScreenBufferSize(hCon, b_size);

  CONSOLE_CURSOR_INFO inf;
  inf.bVisible = false;
  inf.dwSize = 1;
  SetConsoleCursorInfo(handle, &amp;inf);

  SetConsoleTitle(title);
}

void Graphics::ClearScreen()
{
  system(&quot;cls&quot;);
}

void Graphics::DrawAscii(int c, int x, int y, WORD color)
{
  COORD coord = {x,y};

  SetConsoleCursorPosition (handle, coord);
  SetConsoleTextAttribute (handle, color);

  cout &lt;&lt; (char)c;
}

void Graphics::DrawFiend(int f, int x2, int y2, WORD color)
{
	COORD coord = {x2,y2};

	SetConsoleCursorPosition (handle, coord);
	SetConsoleTextAttribute (handle, color);

	cout &lt;&lt; (char)f;
}
</code></pre>
<p>Fiend.cpp:</p>
<pre><code>#include &quot;include/Fiend.h&quot;

void Fiend::Spawnfiend(Graphics&amp; graphics)
{
	graphics.DrawFiend(15, this-&gt;x2 +5, this-&gt;y2 +5, FOREGROUND_RED | FOREGROUND_INTENSITY);
}

void Fiend::Spawnposition(int PosX2, int PosY2)
{
	this-&gt;x2 = PosX2;
	this-&gt;y2 = PosY2;
}
</code></pre>
<p>GetKeystrokes.cpp:</p>
<pre><code>#include &quot;include\GetKeystrokes.h&quot;

bool GetKeystrokes::IsKeyPressed(int key)
{
  if(GetAsyncKeyState(key) &amp; 0x1)
    return true;

  return false;
}
</code></pre>
<p>Map.cpp:</p>
<pre><code>#include &quot;include/Map.h&quot;

void Map::Load(char* path)
{
  FILE *fp;

  // Open file
  fp = fopen(path, &quot;r&quot;);

  // Perform file operations
  char c = getc(fp);

  int zeile = 0;
  int spalte = 0;

  while(c != EOF)
  {
    background[zeile][spalte] = c - 48;

    c = getc(fp);

    if(spalte &lt; 80)
      spalte += 1;
    else
    {
      spalte = 0;
      zeile += 1;
    }
  }

  // Close file
  fclose(fp);
}

void Map::Render(Graphics&amp; graphics)
{
  for(int zeile = 0; zeile &lt; 22; zeile++)
  {
    for(int spalte = 0; spalte &lt; 80; spalte++)
    {
      int wert = background[zeile][spalte];

      if(wert == 1)
        graphics.DrawAscii(205, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 2)
        graphics.DrawAscii(201, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 3)
        graphics.DrawAscii(187, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 4)
        graphics.DrawAscii(200, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 5)
        graphics.DrawAscii(188, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 6)
        graphics.DrawAscii(186, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 7)
        graphics.DrawAscii(5, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
      if(wert == 8)
        graphics.DrawAscii(6, spalte, zeile, FOREGROUND_GREEN);
      if(wert == 9)
        graphics.DrawAscii(176, spalte, zeile, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    }
  }
}

bool Map::IsColliding(int y, int x)
{
  if(background[y][x] == 0)
    return false;

  return true;
}
</code></pre>
<p>Player.cpp:</p>
<pre><code>#include &quot;include/Player.h&quot;

void Player::Initialize(int posX, int posY)
{
	this-&gt;x = posX;
	this-&gt;y = posY;
}

void Player::Render(Graphics&amp; graphics)
{
	graphics.DrawAscii(2, this-&gt;x, this-&gt;y, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
}

int Player::GetX()
{
	return this-&gt;x;
}

int Player::GetY()
{
	return this-&gt;y;
}

void Player::MoveDown()
{
	this-&gt;y+=1;
}

void Player::MoveUp()
{
	this-&gt;y-=1;
}

void Player::MoveLeft()
{
	this-&gt;x-=1;
}

void Player::MoveRight()
{
	this-&gt;x+=1;
}
</code></pre>
<p>Fiend.h:</p>
<pre><code>#pragma once

#include &quot;include/Map.h&quot;
#include &quot;include/Player.h&quot;
#include &quot;include/Graphics.h&quot;
#include &lt;Windows.h&gt;

class Fiend
{
public:

	void Spawnfiend(Graphics&amp; graphics);

	void Spawnposition(int PosX2, int PosY2);

private:

	int x2;
	int y2;

};
</code></pre>
<p>GetKeystrokes.h:</p>
<pre><code>#pragma once

#include &quot;include/Player.h&quot;
#include &quot;include/Map.h&quot;
#include &quot;include/Graphics.h&quot;

class GetKeystrokes
{
public:

  bool IsKeyPressed(int key);

private:
};
</code></pre>
<p>Graphics.h:</p>
<pre><code>#pragma once 

#include &lt;iostream&gt;
#include &lt;stdio.h&gt;
#include &lt;Windows.h&gt;

using namespace std;

class Graphics
{
public:

  void Initialize(short height, short width, wchar_t* title);

  void ClearScreen();

  void DrawAscii(int c, int x, int y, WORD color);

  void DrawFiend(int f, int x2, int y2, WORD color);

private:

  HANDLE handle;
};
</code></pre>
<p>Map.h:</p>
<pre><code>#pragma once 

#include &lt;stdio.h&gt;
#include &lt;Windows.h&gt;
#include &quot;include/Graphics.h&quot;

class Map
{
public:

  void Load(char* path);

  void Render(Graphics&amp; graphics);

  bool IsColliding(int y, int x);

private:

  int background[22][80];
};
</code></pre>
<p>Player.h:</p>
<pre><code>#pragma once

#include &quot;include/Graphics.h&quot;
#include &lt;Windows.h&gt;

class Player
{
public:

  void Initialize(int posX, int posY);

  void Render(Graphics&amp; graphics);

  int GetX();

  int GetY();

  void MoveUp();

  void MoveDown();

  void MoveLeft();

  void MoveRight();

private:

  int x;
  int y;
};
</code></pre>
<p>Fiend.cpp und Fiend.h sollen zuständig sein für das spawnen und für die orientierung der NPC's jedoch wie gesagt derzeit ende im gelände...</p>
<p>Schonma im voraus thx für alle die helfen können / wollen ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/289025/c-ascii-game-weiss-nicht-mehr-weiter</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 14:10:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/289025.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 27 Jun 2011 11:58:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C++ Ascii Game - Weiss nicht mehr weiter... on Mon, 27 Jun 2011 11:59:18 GMT]]></title><description><![CDATA[<p>Hi an all hätte da ne frage wie könnte ich es am besten lösen einen &quot;NPC&quot; in mein<br />
Game einzubauen?<br />
Bin derzeit die ganze zeit nur auf fehler gestossen und weiss nicht wie ich das am besten machen sollte.</p>
<p>Main.cpp:</p>
<pre><code>#include &lt;Windows.h&gt;
#include &quot;include/Map.h&quot;
#include &quot;include/Player.h&quot;
#include &quot;include/Graphics.h&quot;
#include &quot;include/GetKeystrokes.h&quot;
#include &quot;include/Fiend.h&quot;

Graphics graphics;
Player player;
Map map;
Fiend fiend;
GetKeystrokes input;
bool quit = false;
bool first = false;
bool redraw = true;

void Update()
{
  if(input.IsKeyPressed(VK_ESCAPE))
    quit = true;

  if(input.IsKeyPressed(VK_RIGHT))
  {
    if(!map.IsColliding(player.GetY(), player.GetX() + 1))
    {
      player.MoveRight();
    }
    redraw = true;
  }

  if(input.IsKeyPressed(VK_LEFT))
  {
    if(!map.IsColliding(player.GetY(), player.GetX() - 1))
    {
      player.MoveLeft();
    }
    redraw = true;
  }  

  if(input.IsKeyPressed(VK_UP))
  {
    if(!map.IsColliding(player.GetY() - 1, player.GetX()))
    {
      player.MoveUp();
    }
    redraw = true;
  }  

  if(input.IsKeyPressed(VK_DOWN))
  {
    if(!map.IsColliding(player.GetY() + 1, player.GetX()))
    {
      player.MoveDown();
    }
    redraw = true;
  }   
}

void Render()
{
  graphics.ClearScreen();

  map.Render(graphics);

  player.Render(graphics);

  fiend.Spawnfiend(graphics);
}

void main()
{
  graphics.Initialize(24, 79, L&quot;ASCII GAME&quot;);

  map.Load(&quot;.\\data\\maps\\map00.txt&quot;);

  player.Initialize(35,20);

  fiend.Spawnposition(31,70);

  while(!quit)
  {
    Update();

    if(redraw)
    {
      Render();

      redraw = false;
    }    
  }
}
</code></pre>
<p>Graphics.cpp:</p>
<pre><code>#include &quot;include/Graphics.h&quot;

void Graphics::Initialize(short height, short width, wchar_t* title)
{
  handle = GetStdHandle(STD_OUTPUT_HANDLE);

  HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
  SMALL_RECT size;
  COORD b_size;

  size.Left = 0;
  size.Top = 0;
  size.Right = width;
  size.Bottom = height;
  b_size.X = width+1;
  b_size.Y = height+1;

  SetConsoleWindowInfo(hCon, true, &amp;size);
  SetConsoleScreenBufferSize(hCon, b_size);

  CONSOLE_CURSOR_INFO inf;
  inf.bVisible = false;
  inf.dwSize = 1;
  SetConsoleCursorInfo(handle, &amp;inf);

  SetConsoleTitle(title);
}

void Graphics::ClearScreen()
{
  system(&quot;cls&quot;);
}

void Graphics::DrawAscii(int c, int x, int y, WORD color)
{
  COORD coord = {x,y};

  SetConsoleCursorPosition (handle, coord);
  SetConsoleTextAttribute (handle, color);

  cout &lt;&lt; (char)c;
}

void Graphics::DrawFiend(int f, int x2, int y2, WORD color)
{
	COORD coord = {x2,y2};

	SetConsoleCursorPosition (handle, coord);
	SetConsoleTextAttribute (handle, color);

	cout &lt;&lt; (char)f;
}
</code></pre>
<p>Fiend.cpp:</p>
<pre><code>#include &quot;include/Fiend.h&quot;

void Fiend::Spawnfiend(Graphics&amp; graphics)
{
	graphics.DrawFiend(15, this-&gt;x2 +5, this-&gt;y2 +5, FOREGROUND_RED | FOREGROUND_INTENSITY);
}

void Fiend::Spawnposition(int PosX2, int PosY2)
{
	this-&gt;x2 = PosX2;
	this-&gt;y2 = PosY2;
}
</code></pre>
<p>GetKeystrokes.cpp:</p>
<pre><code>#include &quot;include\GetKeystrokes.h&quot;

bool GetKeystrokes::IsKeyPressed(int key)
{
  if(GetAsyncKeyState(key) &amp; 0x1)
    return true;

  return false;
}
</code></pre>
<p>Map.cpp:</p>
<pre><code>#include &quot;include/Map.h&quot;

void Map::Load(char* path)
{
  FILE *fp;

  // Open file
  fp = fopen(path, &quot;r&quot;);

  // Perform file operations
  char c = getc(fp);

  int zeile = 0;
  int spalte = 0;

  while(c != EOF)
  {
    background[zeile][spalte] = c - 48;

    c = getc(fp);

    if(spalte &lt; 80)
      spalte += 1;
    else
    {
      spalte = 0;
      zeile += 1;
    }
  }

  // Close file
  fclose(fp);
}

void Map::Render(Graphics&amp; graphics)
{
  for(int zeile = 0; zeile &lt; 22; zeile++)
  {
    for(int spalte = 0; spalte &lt; 80; spalte++)
    {
      int wert = background[zeile][spalte];

      if(wert == 1)
        graphics.DrawAscii(205, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 2)
        graphics.DrawAscii(201, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 3)
        graphics.DrawAscii(187, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 4)
        graphics.DrawAscii(200, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 5)
        graphics.DrawAscii(188, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 6)
        graphics.DrawAscii(186, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      if(wert == 7)
        graphics.DrawAscii(5, spalte, zeile, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
      if(wert == 8)
        graphics.DrawAscii(6, spalte, zeile, FOREGROUND_GREEN);
      if(wert == 9)
        graphics.DrawAscii(176, spalte, zeile, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    }
  }
}

bool Map::IsColliding(int y, int x)
{
  if(background[y][x] == 0)
    return false;

  return true;
}
</code></pre>
<p>Player.cpp:</p>
<pre><code>#include &quot;include/Player.h&quot;

void Player::Initialize(int posX, int posY)
{
	this-&gt;x = posX;
	this-&gt;y = posY;
}

void Player::Render(Graphics&amp; graphics)
{
	graphics.DrawAscii(2, this-&gt;x, this-&gt;y, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
}

int Player::GetX()
{
	return this-&gt;x;
}

int Player::GetY()
{
	return this-&gt;y;
}

void Player::MoveDown()
{
	this-&gt;y+=1;
}

void Player::MoveUp()
{
	this-&gt;y-=1;
}

void Player::MoveLeft()
{
	this-&gt;x-=1;
}

void Player::MoveRight()
{
	this-&gt;x+=1;
}
</code></pre>
<p>Fiend.h:</p>
<pre><code>#pragma once

#include &quot;include/Map.h&quot;
#include &quot;include/Player.h&quot;
#include &quot;include/Graphics.h&quot;
#include &lt;Windows.h&gt;

class Fiend
{
public:

	void Spawnfiend(Graphics&amp; graphics);

	void Spawnposition(int PosX2, int PosY2);

private:

	int x2;
	int y2;

};
</code></pre>
<p>GetKeystrokes.h:</p>
<pre><code>#pragma once

#include &quot;include/Player.h&quot;
#include &quot;include/Map.h&quot;
#include &quot;include/Graphics.h&quot;

class GetKeystrokes
{
public:

  bool IsKeyPressed(int key);

private:
};
</code></pre>
<p>Graphics.h:</p>
<pre><code>#pragma once 

#include &lt;iostream&gt;
#include &lt;stdio.h&gt;
#include &lt;Windows.h&gt;

using namespace std;

class Graphics
{
public:

  void Initialize(short height, short width, wchar_t* title);

  void ClearScreen();

  void DrawAscii(int c, int x, int y, WORD color);

  void DrawFiend(int f, int x2, int y2, WORD color);

private:

  HANDLE handle;
};
</code></pre>
<p>Map.h:</p>
<pre><code>#pragma once 

#include &lt;stdio.h&gt;
#include &lt;Windows.h&gt;
#include &quot;include/Graphics.h&quot;

class Map
{
public:

  void Load(char* path);

  void Render(Graphics&amp; graphics);

  bool IsColliding(int y, int x);

private:

  int background[22][80];
};
</code></pre>
<p>Player.h:</p>
<pre><code>#pragma once

#include &quot;include/Graphics.h&quot;
#include &lt;Windows.h&gt;

class Player
{
public:

  void Initialize(int posX, int posY);

  void Render(Graphics&amp; graphics);

  int GetX();

  int GetY();

  void MoveUp();

  void MoveDown();

  void MoveLeft();

  void MoveRight();

private:

  int x;
  int y;
};
</code></pre>
<p>Fiend.cpp und Fiend.h sollen zuständig sein für das spawnen und für die orientierung der NPC's jedoch wie gesagt derzeit ende im gelände...</p>
<p>Schonma im voraus thx für alle die helfen können / wollen ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2084766</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2084766</guid><dc:creator><![CDATA[Pwnerer1993]]></dc:creator><pubDate>Mon, 27 Jun 2011 11:59:18 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Ascii Game - Weiss nicht mehr weiter... on Mon, 27 Jun 2011 12:36:31 GMT]]></title><description><![CDATA[<p>Ich fürchte deine Frage ist auf allen Ebenen viel zu vage gestellt, als dass sie irgendjemand beantworten kann.</p>
<p>Was soll einen NPC auszeichen? Wie sieht dein bisheriges Design aus (nicht der Code, sondern was du dir dabei gedacht hast)? Womit hast du Schwierigkeiten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2084802</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2084802</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 27 Jun 2011 12:36:31 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Ascii Game - Weiss nicht mehr weiter... on Mon, 27 Jun 2011 13:10:35 GMT]]></title><description><![CDATA[<p>Pwnerer1993 schrieb:</p>
<blockquote>
<p>...</p>
</blockquote>
<p>Glaubst du wirklich, das jemand sich den gesamten Sourcecode ansieht, ganz davon abgesehen das dieser kein gültiges C++ ist, und auch noch diverse Probleme unnötig einbaut (Warum z.B. die vielen globalen Variablen, &quot;void main&quot; war noch nie gültiges C++...).</p>
<p>Bitte lies dir <a href="http://www.c-plusplus.net/forum/200753" rel="nofollow">Wichtig: Du brauchst Hilfe?</a> durch. Konkret unter anderem &quot;Stell deine Fragen präzise&quot;, &quot;Reduziere Codebeispiele auf das Wesentliche&quot;...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2084817</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2084817</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Mon, 27 Jun 2011 13:10:35 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Ascii Game - Weiss nicht mehr weiter... on Mon, 27 Jun 2011 13:41:21 GMT]]></title><description><![CDATA[<p>Was mir beim flüchtigen Schauen aufgefallen ist:</p>
<p>GetKeystrokes.cpp:</p>
<pre><code class="language-cpp">#include &quot;include\GetKeystrokes.h&quot;

bool GetKeystrokes::IsKeyPressed(int key)
{
if(GetAsyncKeyState(key) &amp; 0x1)
return true;  // das wird immer von der folgenden Zeile überschrieben

return false;
}
</code></pre>
<p>MfG f.-th.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2084829</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2084829</guid><dc:creator><![CDATA[f.-th.]]></dc:creator><pubDate>Mon, 27 Jun 2011 13:41:21 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Ascii Game - Weiss nicht mehr weiter... on Mon, 27 Jun 2011 16:39:39 GMT]]></title><description><![CDATA[<p>f.-th. schrieb:</p>
<blockquote>
<p>Was mir beim flüchtigen Schauen aufgefallen ist:</p>
<pre><code class="language-cpp">bool GetKeystrokes::IsKeyPressed(int key)
{
if(GetAsyncKeyState(key) &amp; 0x1)
return true;  // das wird immer von der folgenden Zeile überschrieben

return false;
}
</code></pre>
</blockquote>
<p>Nicht wirklich - durch das return kommst du gar nicht zur &quot;folgenden Zeile&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2084942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2084942</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 27 Jun 2011 16:39:39 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Ascii Game - Weiss nicht mehr weiter... on Mon, 27 Jun 2011 17:06:56 GMT]]></title><description><![CDATA[<p>f.-th., CStoll: Beide falsch :p Die Funktion arbeitet korrekt, auch wenn sie übermäßig kompliziert geschrieben ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2084951</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2084951</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Mon, 27 Jun 2011 17:06:56 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Ascii Game - Weiss nicht mehr weiter... on Mon, 27 Jun 2011 18:02:39 GMT]]></title><description><![CDATA[<p>ok also ich möchte derzeit nicht das der &quot;NPC&quot; überhaupt was tut (nachher soll er halt den player verfolgen und ihm wehtun etc.</p>
<p>derzeit möchte ich es jedoch nur so hinbekommen das der npc die x und y coordinaten des players abliest und in einem bestimmten radius darum herum &quot;spawnt&quot; also gezeichnet wird, jedoch hänge ich genau da</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/14941">@asc</a> - sorry werd das nächste ma drauf achten. war n bisschen verwirrt als ich hier ankam... (koffein überdosis und schlafentzug) hoffe du nimmst mir dat nicht krumm. und bezüglich der &quot;überkomplizierten&quot; programmierweise... ich progge erst seit nem Monat deswegenm fehlt mir in diesem sinne halt die &quot;Erfahrung&quot;</p>
<p>Ps: in der lage ihn zu zeichnen bin ich ja, nur wenn ich es schaffe ihn zu zeichnen übernimmt er andauernd die posX und posY des Players und klebt somit immer ein Feld neben ihm?! also kein plan wieso er dat tut</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2084975</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2084975</guid><dc:creator><![CDATA[Pwnerer1993]]></dc:creator><pubDate>Mon, 27 Jun 2011 18:02:39 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Ascii Game - Weiss nicht mehr weiter... on Mon, 27 Jun 2011 18:38:11 GMT]]></title><description><![CDATA[<p>naja wenn du es schaffst ihn zu zeichnen und ihm eine position zu geben, dann hasts dus doch fast geschafft</p>
<p>du gibst ihm seine startposition nur einmal mit (das ist eine vorraussetzung ansosnten hast du schon was falsch gemacht - nur so als bedingung, falls das bei dir nicht der fall ist)<br />
und da kannst du jetzt was zu addieren oder abziehen, sprich die position verändern</p>
<p>nach dem prinzip:</p>
<pre><code class="language-cpp">int random(int low, int high)
{
    // srand(time(0)); nur einmal am anfang des programms !!
    return (random() % (high-low)) + low;
}
// ... vorheriges programm
int npc_x = player.getX();
int npc_y = player.getY();

NPC npc1(npc_x + random(-5, 5), npc_y + random(-5, 5));
// weiteres programm z.b. zeichnen
</code></pre>
<p>wobei die random funktion nicht sehr gut ist, ist nich für spezialfälle gerüstet sondern nur wenn high &gt; 0 &amp;&amp; high &gt; low</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085007</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Mon, 27 Jun 2011 18:38:11 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Ascii Game - Weiss nicht mehr weiter... on Mon, 27 Jun 2011 18:45:09 GMT]]></title><description><![CDATA[<p>ok das mit dem random scheint zwar ne lösung zu sein jedoch hat mich das auf die idee gebracht das mit der playerposition erstma wegzulassen und einen (wert == x)<br />
einzufügen um seine position zu bestimmen wobei x gleich ein wert auf meiner map ist.</p>
<p>thx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2085017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2085017</guid><dc:creator><![CDATA[Pwnerer1993]]></dc:creator><pubDate>Mon, 27 Jun 2011 18:45:09 GMT</pubDate></item></channel></rss>