YabbSE-Hack: C/C++ & AGS-Syntax-Highlighting
Verfasst: 03.11.2002, 00:01
(c) 2002 by TheTinySteini, dp and theDon
TheTinySteini & dp - original cpp highlighting
theDon - ags highlighting & adaption to yabbse
so siehts aus:
Source/Subs.php
function preparsecode(), ~ 357
direkt unter
TheTinySteini & dp - original cpp highlighting
theDon - ags highlighting & adaption to yabbse
so siehts aus:
//foo
int main(void)
{
return 23;
}
und so gehts:// --- Konstanten für Richtungen und Laufweite
#define DIR_DISTANCE 10000
#define DIR_SW 1
#define DIR_S 2
#define DIR_SE 3
#define DIR_W 4
#define DIR_STOP 5
#define DIR_E 6
#define DIR_NW 7
#define DIR_N 8
#define DIR_NE 9
int PrevDirection = DIR_STOP;
Die eigentliche Funktion zur Tastatursteuerung sieht folgendermaßen aus:
function Tastatursteuerung() {
// --- Tastatursteuerung ---
int Direction, dx, dy;
// Neue Richtung ermitteln
if ((IsKeyPressed (371) == 1) || (IsKeyPressed (55) == 1)) Direction = DIR_NW;
else if ((IsKeyPressed (372) == 1) || (IsKeyPressed (56) == 1)) Direction = DIR_N;
else if ((IsKeyPressed (373) == 1) || (IsKeyPressed (57) == 1)) Direction = DIR_NE;
else if ((IsKeyPressed (375) == 1) || (IsKeyPressed (52) == 1)) Direction = DIR_W;
else if ((IsKeyPressed (377) == 1) || (IsKeyPressed (54) == 1)) Direction = DIR_E;
else if ((IsKeyPressed (379) == 1) || (IsKeyPressed (49) == 1)) Direction = DIR_SW;
else if ((IsKeyPressed (380) == 1) || (IsKeyPressed (50) == 1)) Direction = DIR_S;
else if ((IsKeyPressed (381) == 1) || (IsKeyPressed (51) == 1)) Direction = DIR_SE;
else Direction = DIR_STOP;
// Vergleich mit aktueller Richtung
if (PrevDirection != Direction)
{
PrevDirection = Direction;
if (Direction == DIR_STOP)
{
StopMoving(EGO);
} // Stopp der Spielfigur
else
{
if (Direction == DIR_NW) { dx = -DIR_DISTANCE; dy = -DIR_DISTANCE; }
else if (Direction == DIR_N) { dx = 0; dy = -DIR_DISTANCE; }
else if (Direction == DIR_NE) { dx = DIR_DISTANCE; dy = -DIR_DISTANCE; }
else if (Direction == DIR_W) { dx = -DIR_DISTANCE; dy = 0; }
else if (Direction == DIR_E) { dx = DIR_DISTANCE; dy = 0; }
else if (Direction == DIR_SW) { dx = -DIR_DISTANCE; dy = DIR_DISTANCE; }
else if (Direction == DIR_S) { dx = 0; dy = DIR_DISTANCE; }
else if (Direction == DIR_SE) { dx = DIR_DISTANCE; dy = DIR_DISTANCE; }
MoveCharacterStraight (EGO, character[EGO].x + dx, character[EGO].y + dy);
}
}
}
Source/Subs.php
function preparsecode(), ~ 357
direkt unter
global settings, $ext
etwas darüber, außerhalb der function preparsecode()//-- begin Code-Highlight-Hack by theDon
$message = cpp_parse($message);
$message = ags_parse($message);
//-- end Code-Highlight-Hack by theDon