Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » 3d matrix

Credits go to gnolam for helping out!
This thread is locked; no one can reply to it. rss feed Print
 1   2 
3d matrix
deps
Member #3,858
September 2003
avatar

Try this instead:
bmp = load_bitmap("Woodland_Tileset.bmp", Null);
You don't need the palette since you don't use 8 bpp graphics.

---
Layers are good, all good things have layers, like onions. Good things also stink. - Trezker
I now have a page and a blog!

vixinu
Member #7,343
June 2006
avatar

It says "Null was not defined in this scope"

deps
Member #3,858
September 2003
avatar

Try null instead. (lowercase N)

---
Layers are good, all good things have layers, like onions. Good things also stink. - Trezker
I now have a page and a blog!

vixinu
Member #7,343
June 2006
avatar

I got it! NULL

wait...it isn't working! No errors, just not working!

1#include <allegro.h>
2 
3int main()
4{
5allegro_init();
6set_color_depth(16);
7set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
8 
9BITMAP *buffer = NULL;
10buffer = create_bitmap(640, 480);
11blit(buffer, screen, 0, 0, 0, 0, 640, 480);
12 
13//load bitmap
14 
15 
16BITMAP *bmp;
17bmp = load_bitmap("Woodland_Tileset.bmp", NULL);
18 
19//load tilemap
20 
21int tilemap[5][5] = {
22 { 96, 96, 96, 96, 96 },
23 { 96, 96, 0, 0, 96 },
24 { 96, 0, 0, 0, 96 },
25 { 96, 0, 0, 96, 96 },
26 { 96, 96, 96, 96, 96 }
27};
28 
29int tile_number = 96; //Set to the tile number wanted
30BITMAP* tileset; //Set to tileset to be loaded
31int tile_size = 32; //Set this to how many pixels big each tile is
32int set_x = tile_number % (tileset->w / tile_size);
33int set_y = tile_number / (tileset->w / tile_size);
34 
35//Put tileset on screen
36 
37for (int y = 0; y < 5; y++)
38{
39 for (int x = 0; x < 5; x++)
40 {
41 int tilesize = 32;
42 //Find out what tileset index to use based on the tilemap at the current (x, y) coordinates
43 int set_x = tilemap[y][x] % (tileset->w / tile_size);
44 int set_y = tilemap[y][x] / (tileset->w / tile_size);
45 //Put it on the buffer
46 // blit(tileset, buffer,
47 //Blit from the tileset to the screen
48 // set_x * tile_size, set_y * tile_size,
49 //starting at the pixel coordinates of the desired tile
50 // x * tile_size, y * tile_size,
51 //put on the screen at the proper place
52 // tile_size, tile_size);
53 //and put only 1 tile's worth of pixels
54 //To put this all together:
55 blit(tileset, buffer, set_x * tile_size, set_y * tilesize, x * tilesize, y * tilesize, tile_size, tile_size);
56}}
57 
58destroy_bitmap(buffer);
59return 0;
60}
61END_OF_MAIN()

deps
Member #3,858
September 2003
avatar

It works, I think. But you are not waiting for the user (you) to press a key or click the mouse. What this piece of code does is to set up a window, draw stuff to it and then quit.

---
Layers are good, all good things have layers, like onions. Good things also stink. - Trezker
I now have a page and a blog!

Kitty Cat
Member #2,815
October 2002
avatar

You only blit the buffer to the screen once when you start the program, but never again after updating the buffer.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

vixinu
Member #7,343
June 2006
avatar

The window just flashes and quits. How do I fix that?

deps
Member #3,858
September 2003
avatar

Wait for a keypress or something?

---
Layers are good, all good things have layers, like onions. Good things also stink. - Trezker
I now have a page and a blog!

vixinu
Member #7,343
June 2006
avatar

It doesn't work

 1   2 


Go to: