FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What about D2?

 
Post new topic   Reply to topic     Forum Index -> Blaze
View previous topic :: View next topic  
Author Message
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Fri Mar 04, 2011 10:44 pm    Post subject: What about D2? Reply with quote

Is Blaze going to continue and be updated for working with D2?

Making a pinball game with Blaze might be cool. I'm more interested useing Blaze with D2 phobos2, though.

I tried compiling with DMD2 and got the biggest thickest amount of output ever!
Back to top
View user's profile Send private message MSN Messenger
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Mon May 09, 2011 4:28 pm    Post subject: Reply with quote

I had a go at getting Blaze to work with D2. I seem to have gotten some where. But then I found that the documentation was different to the actual code. Having said that, I now see you can create html documents from the code.

I guess people get old code to work and use it, without mentioning it to any one.
Back to top
View user's profile Send private message MSN Messenger
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Mon May 09, 2011 4:51 pm    Post subject: Reply with quote

Now I'm trying to get a dot to drop from the top of the screen. But having no success:

Code:

import std.stdio;

version( Windows ) {
   pragma( lib, "liballegro5" );
   pragma( lib, "libdallegro5" );
   pragma( lib, "libjeca" );
}

import jeca.all;
import blaze.all;

void main( string[] args ) {
   scope( exit )
      shutdown_input;
   Init( args );
   
   auto wld = new bzWorld(
      bzAABB(
         bzVec2(1,1),
         bzVec2( 100, 100)
         ),
      bzVec2( 0, 0.01 ),
      false );

   auto rb = new bzBody( new bzBodyDef( bzVec2( 50, 10 ) ), wld );
   
   rb.force = bzVec2( 0, 1 );
   wld.addForce( new bzForceGenerator( rb ) );
   
   auto exit = false;
   do {
      poll_input;
      
      if ( key[ ALLEGRO_KEY_ESCAPE ] )
         exit = true;

      wld.step( 1f, 10, 10 );
      
      //al_clear_to_color( Colour.black );
      
      al_draw_pixel( rb.position.x, rb.position.y, Colour.amber );
      
      al_rest( 0.01 );
      
      al_flip_display;
      
   } while( ! exit );
}

Back to top
View user's profile Send private message MSN Messenger
joelcnz



Joined: 23 Feb 2009
Posts: 76

PostPosted: Mon May 09, 2011 10:36 pm    Post subject: Reply with quote

Ok, now a flatmate has helped me out. So that I can have things fall out of the sky.

Code:
import std.stdio;

version( Windows ) {
   pragma( lib, "liballegro5" );
   pragma( lib, "libdallegro5" );
   pragma( lib, "blaze" );
   pragma( lib, "libjeca" );
}

import blaze.all;
import jeca.all;

const g_meter = 32f;

void main( string[] args ) {
   scope( exit )
      shutdown_input;
      
   Init( args );
   
   ALLEGRO_EVENT event;
   bool getNextEvent() {
      return al_get_next_event( QUEUE, &event );
   }
   
   auto wld = new bzWorld(
      bzAABB(
         bzVec2( 0, 0 ),
         bzVec2( 640 / g_meter, 480 / g_meter )
      ),
      bzVec2( 0f, 3f ),
      false
   );

   auto bonk = new Bonk( 200f, 1f, wld );

   auto exit = false;
   do {
      poll_input;
      
      if ( key[ ALLEGRO_KEY_ESCAPE ] )
         exit = true;

      // keep going through current events till none left, in which case contiune
      while( getNextEvent )
      {
         switch( event.type )
         {
            // close button includes Alt + F4 etc
            case ALLEGRO_EVENT_DISPLAY_CLOSE:
               exit = true;
               
            default:
            break;
         }
      }

      wld.step( 1.0f/60.0f, 10, 10 );
      
      al_clear_to_color( Colour.black );
      
      bonk.draw;
      
      al_rest( 0.01 );
      
      al_flip_display;
      
   } while( ! exit );
}

class Bonk {
public:
   this( real x, real y, bzWorld wld ) {
      auto bd = new bzBodyDef( bzVec2( x / g_meter, y / g_meter ) );
      _rb = wld.createBody( bd );
      
      auto sd = new bzPolyDef;
      sd.setAsBox( 1.0f, 1.0f );
      sd.density = 5;
      _rb.createShape( sd );
      _rb.setMassFromShapes;
      
      _picture = new Bmp( "jblaze.jpg" );
   }
   void draw() {
      al_draw_bitmap( _picture(), _rb.position.x * g_meter, _rb.position.y * g_meter, 0 );
   }
private:
   Bmp _picture;
   bzBody _rb;
}
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Blaze All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group