|
|
This thread is locked; no one can reply to it.
|
1
2
|
| Tile slicing again |
|
Thc-03_Berserk
Member #10,980
May 2009
|
Ok, I gave credits to those helping me out in tile slicing. load image, 1 for x = 1 to 7 The code will probably not run in DarkBasic professional as I done it on the fly. Thanks everybody in advance. Bye, Berserk. |
|
William Labbett
Member #4,486
March 2004
|
Not quite sure if you want to create a bitmap the size you need for mygamegrid. something like this perhaps :- 1BITMAP *grid;
2
3
4
5grid = create_bitmap(TILE_LENGTH * GRID_WIDTH_IN_TILES, TILE_HEIGHT * GRID_HEIGHT_IN_TILES);
6
7
8/* then */
9
10for(x = 0; x < 7; ++x)
11{
12 for(y = 0; y < 23; ++y)
13 {
14 blit(image[y][x], grid, 0, 0, x * TILE_LENGTH, y * TILE_HEIGHT, TILE_LENGTH, TILE_HEIGHT);
15
16 }
17}
Sorry if that's a headache
|
|
Thc-03_Berserk
Member #10,980
May 2009
|
No, sorry. My problem is another. Rem Project: example Rem ***** Main Source File ***** set display mode 800, 600, 32 dim grid(7, 23) load image "blocks.bmp", 1 for x = 1 to 4 for x = 1 to 7 do Please note DarkBasic Professional uses 1 based arrays indexes, while C++ uses 0 based. Thanks in advance for any help. Bye, Berserk. |
|
William Labbett
Member #4,486
March 2004
|
sorry chap. I'm not sure what that code is doing.
|
|
LennyLen
Member #5,313
December 2004
|
I'm assuming you have an array of BITMAPs for your tiles like this: BITMAP *tiles[8];? If you wanted, for example, to blit the 4th tile 60 times to a buffer, in a 10x6 grid, starting from the point 100, 100, you would do this: startx = 100; starty = 100; width = tiles[3]->w; height = tiles[3]->h; for (y = 0; y < 6; y++) { for (x = 0; x < 10; x++) { blit(tiles[3], buffer, 0, 0, startx + x * width, starty + y * height, width, height); } } You should be able to modify that to do whatever it is you want (I'm not sure what that is, to be honest).
|
|
Thc-03_Berserk
Member #10,980
May 2009
|
The code above takes a bitmap and loads it onto the screen. Bye, Berserk. |
|
LennyLen
Member #5,313
December 2004
|
Thc-03_Berserk said: How would I do the same with C++ and Allegro? The code you were given in your last thread (which takes a bitmap, and splits it into tiles) and the code I just gave you (which takes one of those tiles and blits it onto a grid) does almost all of what you want. If you can't figure out how to modify them to suit your needs, then you have absolutely no future as a programmer and should just give up now. If you're just too lazy, and expect everyone to do it fro you, then you're also out of luck. Quote: P.S.: Try the posted code with a trial of darkbasic professional and the attached blocks.bmp. I really doubt that anyone here is going to do that.
|
|
Thc-03_Berserk
Member #10,980
May 2009
|
I just don't know allegro, I also tryed with SDL with a little more luck. Bye, Berserk. |
|
BlackShark
Member #9,796
May 2008
|
well, if you press the esc key, is done == true? -BlackShark |
|
Thc-03_Berserk
Member #10,980
May 2009
|
No, done is not == true. Bye, Berserk. |
|
Tobias Dammers
Member #2,604
August 2002
|
Thc-03_Berserk said: I would like someone converting the code as I don't have a clue of what the posted code does.
This is the <strong>allegro</strong>.cc forum. Allegro is a programming library for <strong>C</strong>, and although it can be used with a lot of other programming languages, either directly as with C++, or through a wrapper or other glue, as with C# or Pascal, your chances of getting useful help here are practically zero unless you communicate in C or C++. --- |
|
Thc-03_Berserk
Member #10,980
May 2009
|
Please don't misunderstand me. I wrote an entyre gameplay in C++ and I know the C++ language. Thanks in advance. Bye, Berserk. P.S.: However, here is a C++ + pseudocode snippet to work on. // ***** Main Source File ***** set display mode 800, 600, 32 // this is clear, sets the display mode to 800x600 32 bits dim grid(7, 23) // this would be equivalent to int grid[7][23]; load image "blocks.bmp", 1 // loads an image for (int x = 1; x <= 4; x++) { for (int x = 1; x <= 7; x++) { while(!(escape_key)) { |
|
LennyLen
Member #5,313
December 2004
|
Thc-03_Berserk said: The only thing I don't know is the Allegro programming library, so I'm in front of a wall trying to develop my first real game (by real I mean a C++ game). There's an expression that gets used quite a bit that's quite applicable in this situation, it goes like this: read the fucking manual.
|
|
Arthur Kalliokoski
Second in Command
February 2005
|
In addition to reading the friendly manual, you might try altering the example programs in small ways to see what happens. They all watch too much MSNBC... they get ideas. |
|
GullRaDriel
Member #3,861
September 2003
|
There is also the wiki link in the main page of a.cc. "Code is like shit - it only smells if it is not yours" |
|
Thc-03_Berserk
Member #10,980
May 2009
|
There should be a reason if I have not read the fucking manual as you sayd. |
|
LennyLen
Member #5,313
December 2004
|
Thc-03_Berserk said: Thanks for your fucking help, fucking community. You were given help, but we're not going to do everything for you. I'm guessing you're leaving then? Good riddance.
|
|
William Labbett
Member #4,486
March 2004
|
Seems to me that it's a question of being realistic. If you want to write a game using allegro but you've got severely limited time with a PC then you've got a problem because you won't get anywhere if you can't learn (which means practice) some C programming. People don't want to write your game for you because they know it won't help you in the long run. My advice is spend the time you've got learning C and look at the examples and it'll become clear what you need to do.
|
|
Schyfis
Member #9,752
May 2008
|
Why not take a look at some of the Allegro example programs? Messing around with the examples is often the best way to learn things. ________________________________________________________________________________________________________ |
|
Thc-03_Berserk
Member #10,980
May 2009
|
Ok, I solved on another forum. Thanks for the exsprite but I already have it and I already gave it a look. Unfortunately I wasn't able to recognize ho to do a sub texture. Now, all I asked was simply create_sub_bitmap( function explanation, but I wasn't knowing that function. Nevermind, I solved on another forum. And no, I'm not gonna leave. Bye, Berserk. |
|
Arthur Kalliokoski
Second in Command
February 2005
|
Thc-03_Berserk said: And no, I'm not gonna leave.
Persistence is a virtue for programmers. They all watch too much MSNBC... they get ideas. |
|
LennyLen
Member #5,313
December 2004
|
Arthur Kalliokoski said: Persistence is a virtue for programmers. So is the ability to think for yourself.
|
|
Tobias Dammers
Member #2,604
August 2002
|
Thc-03_Berserk said: Now, all I asked was simply create_sub_bitmap( function explanation, but I wasn't knowing that function No, that was not all. You pretty much asked for an entire game to be written for you: Thc-03_Berserk said:
The game is ready, it just misses the graphics, sound and input management in order to be playable.
--- |
|
Thc-03_Berserk
Member #10,980
May 2009
|
[code] void grid::redraw(BITMAP ** tiles, BITMAP * screen) { this code is where I split my image in tiles Bye, Berserk. |
|
count
Member #5,401
January 2005
|
Not enough code Where and when do you load what into this variables? Thc-03_Berserk said: BITMAP *buf, *tiles[7], *blocks; // this is at the beginning of my main function What is buf? A buffer? If so why do you blit directly to the screen and not to the buffer? And please note that it is: <code> your code </code>
NOT
|
|
|
1
2
|