Mirage Source http://www.miragesource.net/forums/ |
|
Gravity Tiles http://www.miragesource.net/forums/viewtopic.php?f=210&t=2242 |
Page 1 of 1 |
Author: | Rezeyu [ Sat Jul 07, 2007 9:40 pm ] |
Post subject: | Gravity Tiles |
Just something small I made for my game, and.. I've never written a tutorial yet, so I figured I should try and actually contribute something. This should work in a vanilla MSE, I can't see why it wouldn't. Client Side: Add this to your Constants, under the other tiles: Code: Public Const TILE_TYPE_GRAVITY = 7 Find: Code: If .Type = TILE_TYPE_KEYOPEN Then Call DrawText Under it add: Code: If .Type = TILE_TYPE_GRAVITY Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "Grav", QBColor(Magenta)) Find: Code: If frmMirage.optKeyOpen.Value = True Then .Type = TILE_TYPE_KEYOPEN .Data1 = KeyOpenEditorX .Data2 = KeyOpenEditorY .Data3 = 0 End If Under it add: Code: If frmMirage.OptGravity.Value = True Then .Type = TILE_TYPE_GRAVITY .Data1 = 0 .Data2 = 0 .Data3 = 0 End If Now: Of course you need to go into frmMirage and add OptGravity to the other attributes for the map editor. Server Side: In your Server constants, add this under the other tiles: Code: Public Const TILE_TYPE_GRAVITY = 7 Finally, Find: Code: Sub PlayerMapDropItem Then Dim these: Code: Dim Yloc As Long, x As Long, y As Long In the Sub, find these lines: Code: ' Send inventory update Call SendInventoryUpdate(Index, InvNum) And right under them add this block of code: Code: ' Apply Gravity Yloc = GetPlayerY(Index) For y = 0 To MAX_MAPY For x = 0 To MAX_MAPX If Map(GetPlayerMap(Index)).Tile(x, Yloc).Type = TILE_TYPE_GRAVITY Then Yloc = Yloc + 1 End If Next x Next y And... you're done. If a player tries to drop an object onto a gravity tile, it will move it down one space, if that tile is also gravity type, it will keep being pulled until it hits a non-gravity tile. I used these for ladders in my game, becasue I thought it looked stupid when people dropped items floating on a ladder. Now the itmes fall straight to the bottom of the ladder's base. This can be expanded on easily too.. Maybe make NPCs fall down them, or something. EDIT: Cruzn wrote: In Sub PlayerMapDropItem, Find:
Code: Call SpawnItemSlot(i, MapItem(GetPlayerMap(Index), i).Num, Ammount, MapItem(GetPlayerMap(Index), i).Dur, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index)) Replace With: Code: Call SpawnItemSlot(i, MapItem(GetPlayerMap(Index), i).Num, Ammount, MapItem(GetPlayerMap(Index), i).Dur, GetPlayerMap(Index), GetPlayerX(Index), Yloc) |
Author: | Cruzn [ Sun Jul 08, 2007 4:43 am ] |
Post subject: | Re: Gravity Tiles |
I think you're missing one last part. -- Server Side In Sub PlayerMapDropItem, Find: Code: Call SpawnItemSlot(i, MapItem(GetPlayerMap(Index), i).Num, Ammount, MapItem(GetPlayerMap(Index), i).Dur, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index)) Replace With: Code: Call SpawnItemSlot(i, MapItem(GetPlayerMap(Index), i).Num, Ammount, MapItem(GetPlayerMap(Index), i).Dur, GetPlayerMap(Index), GetPlayerX(Index), Yloc)
|
Author: | Rezeyu [ Sun Jul 08, 2007 6:52 pm ] |
Post subject: | Re: Gravity Tiles |
Hah, yeah forgot that, Updating right now, thanks. |
Author: | Rian [ Sun Jul 08, 2007 7:42 pm ] |
Post subject: | Re: Gravity Tiles |
Props dude. This is a pretty neat tutorial. |
Author: | William [ Wed Jul 11, 2007 4:00 pm ] |
Post subject: | Re: Gravity Tiles |
I didnt really look at it that much since Im in a Internet cafe, but this could be used for a waterfall and such then? |
Author: | Matt [ Wed Jul 11, 2007 4:11 pm ] |
Post subject: | Re: Gravity Tiles |
Yupp. Could easily make it slide npcs and players. |
Author: | wisefire [ Tue Jul 17, 2007 3:51 am ] |
Post subject: | Re: Gravity Tiles |
Change this to work for players and npc and you have yourself a side scrolling rpg. Very Nice indeed. |
Author: | Rezeyu [ Tue Jul 17, 2007 4:19 am ] |
Post subject: | Re: Gravity Tiles |
If you wanted it like that you'd do it with a timer. |
Author: | Braydok [ Tue Aug 14, 2007 2:06 am ] |
Post subject: | Re: Gravity Tiles |
Right now I'm trying to make the item slide down gradually, instead of just jumping to the bottom, I will post when ever I get it figure out, (or someone can figure it out before me and post it.) |
Author: | Rezeyu [ Tue Aug 14, 2007 6:00 pm ] |
Post subject: | Re: Gravity Tiles |
Psst. Look at the way the client uses the Y offset for NPCs and Players. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |