Mirage Source
http://miragesource.net/forums/

Something like CTF
http://miragesource.net/forums/viewtopic.php?f=210&t=2236
Page 1 of 2

Author:  precrid [ Fri Jul 06, 2007 8:19 pm ]
Post subject:  Something like CTF

Hi all,
Does someone know how i can make sometething like this:
A class that hits a flag on a map will change the flag to the color(changing sprite to blue flag) blue for example.
I'm a beginner in coding VB6 so if people want to give me hints or just help me a bit I would be thankfull. A tutorial would be nice but i can't ask that much.

Author:  Lea [ Fri Jul 06, 2007 10:26 pm ]
Post subject:  Re: Something like CTF

You'd probably want to make a flag attribute (similar to block) that can take the value of anyone hitting it. Then just say, "if it's this value, it's this color draw this picture"

Author:  precrid [ Sun Jul 08, 2007 6:21 pm ]
Post subject:  Re: Something like CTF

Dave wrote:
You'd probably want to make a flag attribute (similar to block) that can take the value of anyone hitting it. Then just say, "if it's this value, it's this color draw this picture"

Thanks for helping but like i said i am a beginner in VB6 and a beginner already knows these things: The problem is which variable must i use where must i put the codes.

Author:  Rezeyu [ Sun Jul 08, 2007 6:55 pm ]
Post subject:  Re: Something like CTF

Just name it like.. CTF

Or.. Flag

Author:  Matt [ Sun Jul 08, 2007 6:59 pm ]
Post subject:  Re: Something like CTF

Dave told you what to do, and since he told you what to do, using code that's already in the source, you add the stuff right there. It's really simple, and Dave told you everything you need to know.

The variable or w/e, would be like tile_type_flag.. Something along those lines. Just like the block tile.

Author:  Lea [ Sun Jul 08, 2007 8:10 pm ]
Post subject:  Re: Something like CTF

Follow the other attribute code, copying an attribute (like block) and modify the stuff to act as a flag.

That's the thing with Mirage Source, a lot of the code is already there to copy.

Author:  precrid [ Mon Jul 09, 2007 6:44 pm ]
Post subject:  Re: Something like CTF

Dave wrote:
Follow the other attribute code, copying an attribute (like block) and modify the stuff to act as a flag.

That's the thing with Mirage Source, a lot of the code is already there to copy.

Okay i requested a tutrial and i get some answer that i already know well let say what i understand and what i need to learn okay:
I know how to create the TILE_TYPE_FLAG and all the stuff that comes with it i already did it.
The problem will come now: I don't know the code how to make TILE_TYPE_XXX a tile sprite.
PS. answer in codes and not in normal languages and letting me translate it to codes.

Author:  Lea [ Mon Jul 09, 2007 7:58 pm ]
Post subject:  Re: Something like CTF

Put all of this in modThinkAboutIt

If AddBltFlagsToGameLoop = true then
Goto NextStep
End If
Exit Sub

NextStep:
For each flag in Map
CreateRects
Blt
Next

Author:  precrid [ Mon Jul 09, 2007 8:49 pm ]
Post subject:  Re: Something like CTF

Dave wrote:
Put all of this in modThinkAboutIt

If AddBltFlagsToGameLoop = true then
Goto NextStep
End If
Exit Sub

NextStep:
For each flag in Map
CreateRects
Blt
Next

Okay still not understanding what are you trying to do the only thing yopur doing is getting me confused morethen i already am. Okay using the blt things is right but what after this how to open tile1.bmp and set this sprite and if it hits player change it to another sprite.

Author:  Robin [ Mon Jul 09, 2007 8:53 pm ]
Post subject:  Re: Something like CTF

He's telling you the basic structure of the code.

And the code is doubling as a suggestion to "just think about it".

Go brood over what we've told you and come to the answers on your own.

People rarely want to create a tutorial for someone when they aren't going to use the code themselves.

Author:  Matt [ Mon Jul 09, 2007 8:56 pm ]
Post subject:  Re: Something like CTF

precrid wrote:
Dave wrote:
Put all of this in modThinkAboutIt

If AddBltFlagsToGameLoop = true then
Goto NextStep
End If
Exit Sub

NextStep:
For each flag in Map
CreateRects
Blt
Next

Okay still not understanding what are you trying to do the only thing yopur doing is getting me confused morethen i already am. Okay using the blt things is right but what after this how to open tile1.bmp and set this sprite and if it hits player change it to another sprite.


Dude.. It's really simple to add. We're not just going to hand you the code. You need to learn to do something on your own. And this is super easy. You say you understand how to do something, but yet you don't. You define the tile type, then where it checks all the other tile types, add a check for the new tile type, and if it is that type, then make it execute the code and what not.

Just copy the rest of the stuff. You'll understand better.

Author:  precrid [ Mon Jul 09, 2007 9:24 pm ]
Post subject:  Re: Something like CTF

Okay i think your thinking im sitting here and only let other people work for me i really try but its not workinh i did these things:
Added at ' Tile consants <did this also server side
Code:
Public Const TILE_TYPE_FLAG = 21

Added at ' Blit out attribs if in editor
Code:
If .Type = TILE_TYPE_FLAG Then Call DrawText(TexthDC, x * PIC_X + sx + 8 - (NewPlayerX * PIC_X) - NewXOffset, y * PIC_Y + sx + 8 - (NewPlayerY * PIC_Y) - NewYOffset, "SC", QBColor(BrightRed))


I do not ask for a complete tutorial but only for some explanation because i still don't get it.

Author:  Lea [ Mon Jul 09, 2007 9:27 pm ]
Post subject:  Re: Something like CTF

If you're using a seperate picture file for flags, you'll need to load them into a surface the same way the other graphics are in modDirectX.

To make it switch, you'll just do something like, "If player.x = flag.x And player.y = flag.y then..."
And to change color, you could just have to flag colors and do flag.color = 2

Author:  precrid [ Mon Jul 09, 2007 9:29 pm ]
Post subject:  Re: Something like CTF

Dave wrote:
If you're using a seperate picture file for flags, you'll need to load them into a surface the same way the other graphics are in modDirectX.

To make it switch, you'll just do something like, "If player.x = flag.x And player.y = flag.y then..."
And to change color, you could just have to flag colors and do flag.color = 2

LOL this is the first answer that i understand the first answer that shows me where to search thanks.
So you mean something like this.
Code:
    ' Init flags ddsd type and load the bitmap
    DDSD_flag.lFlags = DDSD_CAPS
    DDSD_flag.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
    Set DD_flagSurf = DD.CreateSurfaceFromFile(App.Path & "\GFX\fn.bmp", DDSD_Flag)
    SetMaskColorFromPixel DD_ItemSurf, 0, 0


fn.bmp contains 3 flag sprites they are all 32x32 so the total size is 32 height and 96 width.
one flag is gray(no team) another flag is red and another one is blue. Another question i got is: must "DDSD_flag.lFlags ,DDSD_flag.ddsCaps.lCaps ,DD_flagSurf" must all words that are red be flag or tile??

player must be class for example class 1 is team 1 class 2 is team 2 for example

Author:  Robin [ Mon Jul 09, 2007 9:31 pm ]
Post subject:  Re: Something like CTF

He's only told you where new surfaces are created.

If you don't even know that, I doubt you'll be able to get the main code done for the system.

Author:  precrid [ Mon Jul 09, 2007 9:46 pm ]
Post subject:  Re: Something like CTF

Robin wrote:
He's only told you where new surfaces are created.

If you don't even know that, I doubt you'll be able to get the main code done for the system.

Okay i don't know anythign im so dumb that even a baby is smarter etc etc etc are you happy now are you ready to tell me some usefull stuff then only cracking me off. I really get tired of those reactions. I know i have to learn but you can't learn if you don't know.

Author:  Lea [ Mon Jul 09, 2007 9:54 pm ]
Post subject:  Re: Something like CTF

Then make it so the flag = the player's class.

Flag is fine, tile is already used for the tiles.

Author:  precrid [ Tue Jul 10, 2007 10:08 am ]
Post subject:  Re: Something like CTF

Okay i think i need this code to change flag sprite
Code:
    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_FLAG Then
        If GetPlayerClass(1) (here must the sprite code that i don't know)
End If
    If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_FLAG Then
        If GetPlayerClass(1) (here must the sprite code that i don't know)
End If


This code could be ofcourse fault well im sure that its fault but i tried.

Author:  Rian [ Tue Jul 10, 2007 4:51 pm ]
Post subject:  Re: Something like CTF

I believe it's something like this:

Code:
If Map(GetPlayerMap(MyIndex)).Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Type = TILE_TYPE_FLAG Then
        If GetPlayerClass(MyIndex) = 0 Then
             Map(GetPlayerMap(Index)).Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Anim = Class0Flag
        End If
        If GetPlayerClass(MyIndex) = 1 Then
             Map(GetPlayerMap(MyIndex)).Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Anim = Class1Flag
        End If
End If


Now, where I have Class0Flag and Class1Flag, you need to count how many tiles your flag is in your tile set. So if Class 0 Flag was the 3rd tile, in the second row, Class0Flag should be replaced with the number 9.

Code:
0123456
789----
-------

Author:  precrid [ Thu Jul 12, 2007 12:28 am ]
Post subject:  Re: Something like CTF

Sonire wrote:
I believe it's something like this:

Code:
If Map(GetPlayerMap(MyIndex)).Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Type = TILE_TYPE_FLAG Then
        If GetPlayerClass(MyIndex) = 0 Then
             Map(GetPlayerMap(Index)).Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Anim = Class0Flag
        End If
        If GetPlayerClass(MyIndex) = 1 Then
             Map(GetPlayerMap(MyIndex)).Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Anim = Class1Flag
        End If
End If


Now, where I have Class0Flag and Class1Flag, you need to count how many tiles your flag is in your tile set. So if Class 0 Flag was the 3rd tile, in the second row, Class0Flag should be replaced with the number 9.

Code:
0123456
789----
-------


sorry but i do not understnad the last code.
Code:
0123456
789

A normal tileset got 8 tiles a row so for example if the flag is on the 8th tile of the first row this wouldn't work? right.
And how does the computer knows the height and the width of each tile.
And at last where must i add his code??

Author:  Robin [ Thu Jul 12, 2007 12:33 am ]
Post subject:  Re: Something like CTF

You're both wrong, it's 7.

Author:  Rian [ Thu Jul 12, 2007 12:39 am ]
Post subject:  Re: Something like CTF

Yes, but I didn't say it was only 6 tiles across. I was just demonstrating how the tiles are numbered. And I'm pretty sure it starts with 0, not 1.

Precrid, that second bit of code wasn't code. It was just a demonstration of tile order. That code probably wont work 100%, as it was just a suggestion, and not actually tried. However, if it did work I'd probably put it in bltTile.

Author:  precrid [ Thu Jul 12, 2007 2:23 am ]
Post subject:  Re: Something like CTF

Sonire wrote:
Yes, but I didn't say it was only 6 tiles across. I was just demonstrating how the tiles are numbered. And I'm pretty sure it starts with 0, not 1.

Precrid, that second bit of code wasn't code. It was just a demonstration of tile order. That code probably wont work 100%, as it was just a suggestion, and not actually tried. However, if it did work I'd probably put it in bltTile.

Okay that code would not help could you post a code that could help please.

Author:  Lea [ Thu Jul 12, 2007 2:29 am ]
Post subject:  Re: Something like CTF

The reason we're trying to help you is because we want you to get it working, but we're getting to the point where we're writing it for you.

It's hard for us to give code on a feature that is unique like this one, because we don't have the code available to us. That means we either need to add the feature to a blank MS and see what we need to do, which is a lot of time and effort that we'd rather spend elsewhere, or make up some code on the spot that probably wont work.

I'm sure you can see the problem with each method.

As for drawing the flags, look at the way Tiles are drawn. There's rec, and rec_pos. Those are both rectangles saying the source and destination. You just need to use the correct source rect to pick which color flag you draw. It measures in pixels so it should be easy to figure them out. Useful constants are PIC_X, PIC_Y (which are both = 32 = Tile Size)

Pretty much copying most of the code from BltTile.

Author:  Rian [ Thu Jul 12, 2007 2:55 am ]
Post subject:  Re: Something like CTF

precrid wrote:
I'm a beginner in coding VB6 so if people want to give me hints or just help me a bit I would be thankfull. A tutorial would be nice but i can't ask that much.


The code I posted will probably work if you put it in Sub bltTile, which is in modGameLogic. That is of course assuming that your flags are in your tile set. Did you try the code at all? Or just assume that it wouldn't work because it's untested?

Page 1 of 2 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/