Kleine Spielerrei mit BMax und C++ (Types und Structs)

Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Neue Antwort erstellen

kog

Betreff: Kleine Spielerrei mit BMax und C++ (Types und Structs)

BeitragFr, Nov 07, 2008 12:18
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich habe heute ein bisschen wieder mit BBObject und co. gearbeitete, da ich es für mein neues Projekt brauche.
Da dachte ich, ich mache ein paar Tests. Vielleicht helfen jemanden diese paar Codezeilen auch um etwas Basteln zu können oder um es zu verstehen:

test.cpp
Code: [AUSKLAPPEN]
/*
   2008 by Aregger 'k.o.g.' Benjamin
*/

#include <windows.h>
#include <stdio.h>

#include <brl.mod/blitz.mod/blitz_types.h>

struct BBTestType;
struct BBTestType2;

struct BBTestType{
   BBClass*      clas;
   int            refs;

   int            i;
   BBTestType2*   t;
};

struct BBTestType2{
   BBClass*      clas;
   int            refs;
   
   float         f;
   int            i;
};

extern "C"
{
   BBTestType *Test(void);
   void PrintTest(BBTestType *t);
   void ChangeI(BBTestType *t,int i);
}

BBTestType *Test(void)
{
   BBTestType *k=new BBTestType;
   k->i=10;
   k->t=new BBTestType2;
   k->t->f=100.0;
   k->t->i=100;

   return k;
}

void PrintTest(BBTestType *t)
{
   printf("i:       %i\r\nt.f:     %f\r\nt.i:     %i\r\n",t->i,t->t->f,t->t->i);
}

void ChangeI(BBTestType *t,int i)
{
   t->i=i;
}


test.bmx
Code: [AUSKLAPPEN]
SuperStrict

Framework pub.stdc
Import "test.cpp"
Function Print(Str:String="")
   WriteStdout str+"~n"
End Function

Extern "C"
   Function Test:TestType()
   Function PrintTest(t:TestType)
   Function ChangeI(t:TestType,i:Int)
End Extern

Type TestType
   Field i:Int
   Field t:TestType2
End Type

Type TestType2
   Field f:Float
   Field i:Int
End Type

Local t:TestType
t=New TestType
t.i=20
t.t=New TestType2
t.t.f=200.0
t.t.i=200

Print "BMax Created Entry---------------------------------------------------------------------------"
Func(t)
t=Null
Print
Print "C++ Created Entry----------------------------------------------------------------------------"
t=Test()
Func(t)
Print
Repeat
   Delay 2
Forever

Function Func(t:TestType)
   If Not t Return
   
   Print "BMax Print-----------------------------------------------------------"
   Print
   Print "i:       "+t.i
   Print "t.f:     "+t.t.f
   Print "t.t.i:   "+t.t.i
   Print
   Print "C++ Print------------------------------------------------------------"
   Print
   PrintTest(t)
   Print
   '--------------------------------------------------------------------
   t.i=1337
   Print "BMax Print-----------------------------------------------------------"
   Print
   Print "i:       "+t.i
   Print "t.f:     "+t.t.f
   Print "t.t.i:   "+t.t.i
   Print
   Print "C++ Print------------------------------------------------------------"
   Print
   PrintTest(t)
   Print
   Print "---------------------------------------------------------------------"
End Function


DemoEXE: http://www.kognetwork.ch/testexe.rar

naja Falls es unbrauchbar erscheint, kann man den Thread wieder löschen

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group