Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - thydowulays

Pages: 1 ... 4 5 [6] 7 8 ... 13
76
Axe / Re: thydowulays's Complete n00bs guide to Tilemapping in Axe
« on: January 29, 2012, 10:47:24 pm »
@saintrunner Yes I will do that first thing tomorrow morning!

EDIT:@squidgetx Okay, that makes perfect sense, although for n00bs like me, I'm going to keep the !If in the example. But I will be using this instead of !If from now on :)

77
Computer Programming / Re: C++ Error help
« on: January 28, 2012, 02:05:46 pm »
Well, the problem is that MinGW can't "connect" with it's internal parts. I can't really help you with fixing MinGW but if you got Code::Blocks and put your code in there, it should work fine.

78
Miscellaneous / Re: Puzzles of the Twisty Variety
« on: January 28, 2012, 12:59:40 am »
Wow, nice collection. Yeah, when I got my rubiks cube back in 2009, I couldn't put it down. I have (had):
-3 3x3's - 2 Rubiks 1 diansheng (I lost it :(
-1 4x4 - Some asian brand -.-
-1 5x5 Rubiks
-A pyraminx
-A megaminx
-A square one
-A Skewb
-2 keychain cubes - 1 rubiks 1 from the SC Governers school
-Rubiks slide

Yeah its not very big, but at the time I was really interested in cubing, I had little to no money so, it was good enough for me. :)

79
Axe / Re: thydowulays's Complete n00bs guide to Tilemapping in Axe
« on: January 26, 2012, 11:05:27 pm »
@parserpadwan Thanks for that! I'll check that out. @Qwerty.55 Yes! Thank you! I was going to do that but I didn't have enough time :) @squidgetx Thanks for the optimization! How does it work though?

80
Axe / Re: thydowulays's Complete n00bs guide to Tilemapping in Axe
« on: January 26, 2012, 04:25:36 pm »
Sidescrolling can be implemented, but to be honest, I really don't know how.

81
Axe / Re: thydowulays's Complete n00bs guide to Tilemapping in Axe
« on: January 25, 2012, 10:55:27 pm »
Sure thing DJ! Glad you liked it!

82
Axe / Re: thydowulays's Complete n00bs guide to Tilemapping in Axe
« on: January 25, 2012, 10:51:16 pm »
Thanks! I just felt as though there wasn't enough tilemapping tutorials to go around Omnimaga..... :D

83
Axe / thydowulays's Complete n00bs guide to Tilemapping in Axe
« on: January 25, 2012, 10:41:16 pm »
Okay, so you've seen them everywhere. Mario, Pacman, and tons of others all use a method for displaying a "map" on the screen, and easy and custom collisions with it. Although there are many out there, this Axe tilemapping tutorial will hopefully boost your knowledge of tilemapping to a pretty decent level. Enough of me blabbering, let's get started!

Okay, so the first part of the tilemap is the map itself. Most maps are 12 wide, and 8 tiles high. Tiles are 8x8 sprites that are used in a tilemap, that can be collided with, drawn, or changed dynamically. You will learn how to do all this later on in the lesson. NOTE: This lesson only covers non-scrolling tilemaps.

When drawing a map, you have to pay attention to the number that the tile is. This will always be two digits in length, and the numbers in it correspond to the sprites that you put in the tile. For example - tile 00 is blank, while tile 01 would hold a sprite value.

Here is an example of a map:

[010101010101010101010101]->GDB1 // You will learn why this is on top later
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000010101]
[010000000000000001010101]
[010101010101010101010101]


The reason we put the GDB1 at the top, is because that ensures that our map compiles like it should, without doing that will only display one row of the map.

That map is 12x8, because there are 24 numbers in each row (remember that one tile is two digits) and there are 8 columns.
The map would look like this drawn:

XXXXXXXX
X           X
X           X
X           X
X           X
X      XXXX
X    XXXXX
XXXXXXXX

However, we haven't even defined what 01 is yet! This is what we will be doing now:

NOTE: The tile number 00 will ALWAYS be an empty tile, any numbers after that YOU will have to define yourself.

To add a tile to a tile map, you simply define a certain sprite. We will be using Pic1 for this, as it is easy to understand.

Here is an example:

[010101010101010101010101]->GDB1 // Same tilemap as earlier
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000010101]
[010000000000000001010101]
[010101010101010101010101]

[FFFFFFFFFFFFFFFF]->Pic1 // A simple black block sprite. How does it know which picture variable to use? We will be learning that next.


Basically, that code makes every tile labeled "01" a block sprite. Every tile labeled "00" is an empty one.

How does it know which picture variable to use?

When you actually draw the tilemap using a routine I will give you, there is a line in the routine that is this: Pt-On(A*8,B*8,T*8+Pic1). Just replace the Pic1 with whatever picture variable you chose.

However, we will not be doing the routine until later. Right now I will focus on adding more than 1 tile sprite.

This is how it's done:


[010101010101010101010101]->GDB1 // Same tilemap as earlier
[010202020202020202020201] // Now just add 02 as the tile, and the second sprite will show up
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000010101]
[010000000000000001010101]
[010101010101010101010101]

[FFFFFFFFFFFFFFFF]->Pic1 // A simple black block sprite. How does it know which picture variable to use? We will be learning that next.
[0F0F0F0F0F0F0F0] // We only put the ->Pic1 on the first tile sprite, everywhere else it is not needed.


So now, the sprite [0F0F0F0F0F0F0F0F] can be treated as 02, so wherever you put 02 in your tilemap now, [0F0F0F0F0F0F0F0F] will show up there.

You got that down? I think you need a visual. Say that 01 was a smiley face, and 02 was a frowny face. This is what the example up there would do:
:) :) :) :) :) :) :) :)
:) :( :( :( :( :( :( :)
:)                         :)
:)                         :)
:)                         :)
:)                 :) :) :)
:)             :) :) :) :)
:) :) :) :) :) :) :) :)
Kudos for Qwerty.55 for fixing my smiley map :)

Thats all for defining tilemaps, now we need to draw them. I like to use a simple, yet flexible routine for this. Here it is (don't be intimidated, it's not that confusing)


<Insert tilemap here>
Repeat getKey(15) //Tilemap will show until user presses CLEAR
For (B,0,7) // This statement here will take care of drawing the tiles from top to bottom. The number at the end is always one less than the height of the map
For (A,0,11) // This statement takes care of drawing the left to right tiles.
{B*12+A+GDB1}->T // This turns the actual tilemap data into the picture for the tilemap. NOTE: If your tilemap isn't 12x8, change the 12 in this to whatever it is.
If T //Don't mind this, but you must have it in your code
T--
Pt-On(A*8,B*8,T*8+Pic1 // This actually draws the tilemap. Replace Pic1 with whichever variable you defined your tile sprites with earlier.
End
End
End
DispGraph //Displays the tilemap
ClrDraw
End


I know that may seem a bit intimidating, but give it a try!

And now a finished (sort of) product:

[010101010101010101010101]->GDB1
[010202020202020202020201]
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000010101]
[010000000000000001010101]
[010101010101010101010101]

[FFFFFFFFFFFFFFFF]->Pic1
[0F0F0F0F0F0F0F0]

Repeat getKey(15)
For (B,0,7)
For (A,0,11)
{B*12+A+GDB1}->T
If T
T--
Pt-On(A*8,B*8,T*8+Pic1
End
End
End
DispGraph
ClrDraw
End


You can also store your tilemap in a second program. Such as this


PROGRAM:TILEDATA
[010101010101010101010101]->GDB1
[010202020202020202020201]
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000000001]
[010000000000000000010101]
[010000000000000001010101]
[010101010101010101010101]

[FFFFFFFFFFFFFFFF]->Pic1
[0F0F0F0F0F0F0F0]

That would be called prgmTILEDATA, now all you have to do is put it in your main program. (We will be using prgmTILESRC)


PROGRAM:TILESRC
Repeat getKey(15)
For (B,0,7)
For (A,0,11)
{B*12+A+GDB1}->T
If T
T--
Pt-On(A*8,B*8,T*8+Pic1
End
End
End
DispGraph
ClrDraw
End
Return //Always put a return statement before you include any subprograms
prgmTILEDATA //Now it should work the same as before, just less crowded.


Anyways, that's all fine and dandy, but what if we wanted a player that would be able to walk through one tile, and not be able to walk through another?
It's actually pretty simple.

PROGRAM:TILESRC
48->X
40->Y
//Simple variables to store the position of the player that you can move.
Repeat getKey(15)
For (B,0,7)
For (A,0,11)
{B*12+A+GDB1}->T
If T
T--
Pt-On(A*8,B*8,T*8+Pic1
End
End
End
Pt-On(X,Y,[FFFFFFFFFFFFFFFF]) //Displays a block sprite at position X,Y
DispGraph
ClrDraw

If getKey(4) //If the user presses the Up arrow
Y-8->Y //Move the player one tile up
Pause 500 //Make it a little slower
End

If getKey(1) //If the user presses the Down arrow
Y+8->Y //Move the player one tile down
Pause 500 //Make it a little slower
End

If getKey(2) //If the user presses the Left arrow
X-8->X //Move the player one tile left
Pause 500 //Make it a little slower
End

If getKey(3) //If the user presses the Right arrow
X+8->X //Move the player one tile right
Pause 500 //Make it a little slower
End


End
Return
prgmTILEDATA


That adds basic movement for a block sprite. Now I will be showing you a simple, yet effective routine for getting individual tiles. (Thanks, leafy :) )
Add this right after prgmTILEDATA:

Lbl GT
{r2/8*12+(r1/8)+GDB1}
Return

Basically, that routine tests to see if there is a tile at position X,Y. You can also test its number, like if it's a 01 tile or not.

Here's how you would add collision:


PROGRAM:TILESRC
48->X
40->Y
Repeat getKey(15)
For (B,0,7)
For (A,0,11)
{B*12+A+GDB1}->T
If T
T--
Pt-On(A*8,B*8,T*8+Pic1
End
End
End
Pt-On(X,Y,[FFFFFFFFFFFFFFFF])
DispGraph
ClrDraw

If getKey(4)
!If sub(GT,X,Y-8)=1 If there is NOT a tile with a number of 01 directly ABOVE the player, then move.
Y-8->Y
Pause 500
End
End

If getKey(1)
!If sub(GT,X,Y+8)=1 If there is NOT a tile with a number of 01 directly BELOW the player, then move.
Y+8->Y
Pause 500
End
End

If getKey(2)
!If sub(GT,X-8,Y)=1 If there is NOT a tile with a number of 01 directly to the LEFT of the player, then move.
X-8->X
Pause 500
End
End

If getKey(3)
!If sub(GT,X+8,Y)=1 If there is NOT a tile with a number of 01 directly to the RIGHT of the player, then move.
X+8->X
Pause 500
End
End

End
Return
prgmTILEDATA
Return
Lbl GT
{r2/8*12+(r1/8)+GDB1} //Our routine for testing tiles.
Return



Whoo! That's a lot of code! But, If you did it correctly, you will notice that you can't move past the solid black tiles! Let's take a second to study this line:

!If sub(GT,X,Y-8)=1

How does that line work? Well, the ! tests to see if it is NOT there, and the If sub(GT,X,Y-8) tests to see if there is a tile directly above the player, and the =1 after that tests to see if the tile's number is 01. If it said =2, then it would test to see if the number was 02. Simple stuff.

You can use this simple tilemapping frameworks for lots of games, including platformers (with a little modification) as it is easy and effective.

Thanks so much to Runer112, aeTIos and Leafiness0 for teaching me tilemapping, and your routines!

I hope you found this tutorial helpful, leave any questions or comments below.

I will be uploading some screenshots to go with this tutorial soon, but in the mean time, have fun with this!

84
Axe / Re: Help with tilemap collision?
« on: January 25, 2012, 09:42:04 pm »
Parser, to erase an individual tile from the map, you basically take leafy's routine:
Code: [Select]
Lbl GT
{r2/8*12+(r1/8)+GDB1}
Return
And turn it into this:
Code: [Select]
Lbl ST
{r2/8*12+(r1/8)+GDB1}->r3
Return
Then, you would just have to do ST(X,Y,0 and the tile at position X,Y will be converted into 00.
What do you mean by fast drawing?

EDIT: Leveled up! W00t!

85
The Axe Parser Project / Re: Features Wishlist
« on: January 24, 2012, 08:01:01 pm »
Oh I see....
Hmm..... well I can't really help you there.

86
The Axe Parser Project / Re: Features Wishlist
« on: January 24, 2012, 04:52:31 pm »
I actually do not know if this exists in Axe, but in BASIC, "line(X1,Y1,X2,Y2,0)" turns off a line.  Notice the zero.
This would be most helpful in my newest creation, Dodge2.

Thundermagnet, for what you're doing there is actually a pretty simple way to do it. As you may know, when a line goes off the screen, it disappears. So basically if you wanted a line to "turn off" all you would have to do is this: Line(X,X,X,100). Doing so will make the line disappear, and all you have to do is, to get it back, just change the 100, to a variable or a number below 96. Hope it helped!

87
Site Feedback and Questions / Re: Grammer language board
« on: January 23, 2012, 09:43:32 pm »
I think this is a really great idea because I for one, have no idea how to program in Grammer at all and I would love to use it, because it looks pretty amazing.

88
Site Feedback and Questions / Re: Grammer language board
« on: January 23, 2012, 09:05:48 pm »
:D Did you decide to write this post when I said this in IRC? Or where you thinking about this for a while?

89
Computer Projects and Ideas / Re: Rain my first C++ game!
« on: January 20, 2012, 10:53:34 pm »
No, you dont need a cin.ignore() before cin.get().

90
Miscellaneous / Re: What is your avatar?
« on: January 20, 2012, 10:35:03 pm »
My avatar is nothing special. And you just lost the game.

Pages: 1 ... 4 5 [6] 7 8 ... 13