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

![]() |
kogBetreff: Kleine Spielerrei mit BMax und C++ (Types und Structs) |
![]() Antworten mit Zitat ![]() |
---|---|---|
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 "C++ Created Entry----------------------------------------------------------------------------" t=Test() Func(t) Repeat Delay 2 Forever Function Func(t:TestType) If Not t Return Print "BMax Print-----------------------------------------------------------" Print "i: "+t.i Print "t.f: "+t.t.f Print "t.t.i: "+t.t.i Print "C++ Print------------------------------------------------------------" PrintTest(t) '-------------------------------------------------------------------- t.i=1337 Print "BMax Print-----------------------------------------------------------" Print "i: "+t.i Print "t.f: "+t.t.f Print "t.t.i: "+t.t.i Print "C++ Print------------------------------------------------------------" PrintTest(t) Print "---------------------------------------------------------------------" End Function DemoEXE: http://www.kognetwork.ch/testexe.rar naja Falls es unbrauchbar erscheint, kann man den Thread wieder löschen |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group