Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / One sprite code, for all the same sprites?

Author
Message
Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 15th Dec 2007 19:04 Edited at: 15th Dec 2007 19:05
In my game when you touch a wall (which is just a tile 40x40) the sprite stops...

Could i paste hundreads of the SAME sprite (the wall) on the level and make them all share their collision callback?

fency federejshn
dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 15th Dec 2007 20:22
Yes, if you use a class.

dbPrint ( "Sig" );
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 15th Dec 2007 22:11
dbGamerX - I agree with you - but I don't think Fency is there just yet.

Fency - So you got the beginning of a level going eh? Good Man!

BTW - After looking at your code earlier - and the MOD's ( % ) stuff - even numbers - etc all of that - I was pretty impressed with your design/thinking ability You'll get the C++ syntax/logic down with time - but your 10,000ft altitude vision is crystal clear Bro!

Now - Let's step back for minute. dbGamerX is eluding that you can have a "class" or Function that just "knows" where all youre "sprites" are and make one function call that will handle it. It would to loop through a list of them in memory - just wouldn't look like it - unless you looked at the function/class itself - I could be wrong here - but that's what I THINK he means - so ... moving forward.

you know how you said GDK Sprite Collision Won't work for you?

After viewing your code I know it would. Further more - it tells you the Sprite that was hit.

So - rather than calling a loop 100,000 times to see if your player hit 1, or hit sprite , or hit sprite 3...... just do this:

1: Store the SPRITE ID of your FIRST LEVEL Tile.

2: Plot your level (make a ton of sprites if you wish - and place them...just the level ones).

3: Store the SPRITE ID of your last one. (Assuming they are in order like Sprite ID 100, 101, 102 etc.

Now in you main loop - use the GDK sprite collision and note the ID of the sprite your player dude hit. If its >=FIRST_LEVEL_TILE_ID and <=LAST_LEVEL_TILE_ID then YOU hit a wall - period!

Less work when you think about it. DBPro does all the looping for you there - and it's probably faster (could be wrong here too) than trying to make your own collision routine.

dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 15th Dec 2007 22:18
You nailed it, jason That's exactly what I meant.

Rock on,
dbGamerX

dbPrint ( "Sig" );
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 15th Dec 2007 23:10 Edited at: 15th Dec 2007 23:10
@dbGamerX - Cool

another thought - You could also take into account you are using fixed sized "tiles" and make an array.

Two functions - with your MOD % tricks - could be used to discern where in a "grid" you are. If the Grid square you are THINKING about sliding to is a "WALL" than prohit the move altogether - and forget collision for level walls entirely. This would just PREVENT moves in that direction.

Sample "Grid" level

Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 16th Dec 2007 00:05 Edited at: 16th Dec 2007 00:06
Thanks for the compliments, but I am afraid I am too unexperienced with C++, My OOP skills are limited, i know the classes the inheritance, pointers , references and all of that basic stuff... but who can expect more I'm only programing for about 7 months,
(3 months C++ the rest was the easy life in Delphi)

Done with that let's get one with the tile game.

Jason ma man, i got the first post loud and clear, but i didn't quite get the second one...

I'm down with the aray thing i used that trick on my previos tile game

this is my level loading function... from the previous game




I used a file ("fency.map") to load my tiles, cause i made a level editor that would export my map (aray) int to .txt or notepad...

It was more practical.

But i still used my collision function for checking collision?

fency federejshn
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 16th Dec 2007 01:32
Ma Man! All I meant was that if you use math - to turn the SPRITE X and Y from somthing like 80,160 and turn that to something that would work with your "LEvel" grid array like 2,4 (x,y) You could (when checking the keypresses - right before it decides its cool to move) Add one more Check - Take the these Sprite coords - make em into "coords" in your grid - and then if the user is pressing right and Grid: CurrentX+1,CurrentY <> EMPTY (a wall) Skip out - don't bother letting the player even try to slide

Was that a little easier to get? BTW - Sounds like you are SCREAMING - at learning programming!

Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 16th Dec 2007 12:40
HO HO HO, i get it!!!

if we have a matrice

level[5][5]
00 00 00 00 00
00 01 01 01 00
00 00 02 01 00
00 00 00 01 00
00 00 00 00 00

01-wall
00-nothing
02-da playa

then if i press right


then
x- the x part of the matrice
y- the y part of the matrice

x=playa.x+=1; if (level[x][y].type > beginner_wall && level[x][y].type < beginner_wall)
{
//don't move!!!
}
else
playa.x+=1;

did I get it right?

fency federejshn
dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 16th Dec 2007 15:45 Edited at: 16th Dec 2007 15:51
Exactly. But I have an easier way. What I do if I needed sprites is make layers.

Say I have ground.jpg. I make ground.jpg the floor.

Then I have wall.jpg, which I will store on a new layer (2nd layer). I set its coordinates and tile it on its X-axis to cover the wall on the top part of the screen. Then I use a class/function to set the second layer (wall.jpg) to say, solid. When the player and sprite overlap, false is returned, preventing the player from moving.

I have a class (not function) like that in Ogre, but I still have to convert it to DGDK.

Since I don't make 2D games anymore, I can't find that class lol. I think I deleted it

Anyways, it's easy as 1-2-3. If you have experience in PhotoShop or PaintShopPro etc, it should be a snap on understanding layers.

Though, I do not know if DGDK supports image layers.

BUT, it isn't totally awesome because say you have a cliff. You'll have to be standing on "solid" air to not move further into the trench. You'll need to declare the ground before the trench as "solid" in order to return false.

Once you get the hang of it, it's easier to understand than most complicated mathematical equations. But again, math does much more than what image overlapping collision does.

dbPrint ( "Sig" );
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 16th Dec 2007 16:24
Yeah - You got Bro!

I think dbGamerX is very enthused! That's Cool. He's (allow me to try to translate again) basically doing the same thing - but in a way that he can "DRAW" the matrix with graphix - same a picture - and use that picture for the same basic idea!

But you got the idea!

when you can cut the number of steps you need to do per loop - the better. Looping through a ton of stuff - usually starts to get "heavy" THOUGH - BEWARE - Sometimes the enemy IS NOT looping etc - its straight up rendering!

There is a same of code here called FRUSTRUM LIMB CULLING. Basically - it allows you effectively "remove limbs" from the Rendering stuff - based on if they are in the screen or not. This code is long - full of math - uses complex directx style matrix commands (Not the matrix in dbpro/gdk that you can make lame terrain from) its beefy - BUT - because it has such a dramtic effect on how much work the video card has to do - its been commented that when you use it - "Something Magical Happens to your framerates".....So that means I NEED to get it working in GDK ... ugh ... I Want Magical though

dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 16th Dec 2007 17:27
Rock on, Jason!

Building from that, Frustrum limb culling allows massive maps to be displayed in an efficient frame rate than when you don't use it.

Say you have 2 cubes:


When the player is facing North, their graphics card will render the cube at north. BUT, the cube at South will also be rendered, but the camera position and direction will be facing north, so you won't see the cube at south.

By using limb culling you can eliminate most of the work the user's video card has to buffer.

Result:



So, after this we get:
1. Fast, smooth rendering maps
2. More compatibility with players' computers
3. No lag

dbPrint ( "Sig" );
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 16th Dec 2007 17:31
Good Day to you dbGamerX

I was glad to see your post - for the hello - how are you thing and for this:

Quote: "2. More compatibility with players' computers"


I never really thought of that - but it makes sense - by taking it a little easier on the gfx card demands - more people can use. One more reason to laborously chore at getting Frustrum (limb) Culling working in DarkGDK

dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 16th Dec 2007 18:04 Edited at: 16th Dec 2007 18:06
Hi Jason,
Do you know when they might implement it?

EDIT: You know, they should add it to the TODO list for the next major release... The closer DGDK gets to being a complete game engine, the closer I get to paying for it and getting the commercial version.

dbGamerX

dbPrint ( "Sig" );
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 16th Dec 2007 18:44
I don't know. One of the cool things I noticed in some other engines is they "Just Do that" Period. No Hide/versus Exclude - that's all "automatic".

One Engine I saw - when you place an object - you give it mass, density, and could even associate sounds like "limbs" coming from the object - so you just moved the object around - and physics was a simple yes/no - and sounds you just turn em on and set volumes and they "stick" to the object where you placed em - like a limb.

On the flip side - by having disconnected stuff - not all integrated - you have a little more flexibility probably.

I do agree with you in that we probably should not have to worry about such things as culling. I would like it if we had a simple flag - to enable auto culling (of limbs and complete objects) - or be able to turn it off if that helped someone.

So I have no idea if TGC will/is/planing anything - I'll just try to get the the frustrum culling thing sometime soon - soon after I nail this "Terrain" issue I'm dealing with - they go hand in hand though One for Looks - the other for display speed etc

[sorry to have kinda hi-jacked the thread]

dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 16th Dec 2007 18:58
lol, I'm lazy. Once you get the limb culling working, can you share it with me? Right now I'm working on a script that will play AVI/MPEG movies full screen. It uses mscorlib and the Windows SDK. I'll share that with you one I'm done I'm going to post a thread so everyone can use it.

Right now, I can only view the first frame, and I'm working on looping through the frames. I managed a way to "extract" DirectShow from the Windows SDK, so compilation is not too slow.

(BTW, we're going so off topic from matrices)

dbPrint ( "Sig" );
Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 16th Dec 2007 19:54
Holly Sh**** the last few post were chinese to me...

btw.. Every day i "talk" to you guys i get closer to converting my tile game to this engine, and giving it more fency effects and cool stuff.

Now Let's talk tile...

Right now I'm thinking of an efficent OOP system on my game that would be capable of loading many levels..

I was thinking of a Game class that would call a Level class object
(which is a level) and a level is compoused of a 2D aray,

every level should have members like,

level_width,Level_height,Number_enemy_tanks,Num_enemy_spiders..

and most importently, the aray:

level_1[level_width][level_height]...


The Game class would have the most inmortent function that is Run
Run Would take 2 parameters, the ENUM which could be {LEVEL,HELP,OPTIONS,CREDITS....}
and if the enum is LEVEL it would also take the LEVEL OBJECT... on

That would be the OOP sistem i VERY SHORT therms.

I need help with the slap_level function

I previously made that function like this




Now i need a new one that would make many sprites, i tried to write it today but the results were misterious...

If you could show me/give me an example of that slap function that would ue a 2D aray, (i need a 2D aray to help me with the collision)

That function would take for a parameter the LEVEL OBJECT.

holly s***** this is a long post

fency federejshn
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 16th Dec 2007 22:12
I write long posts - that posts wasn't that long

As for your slap Level - I'm hoping someone else will jump on board. I'm working on something pretty heavy in the Vertice department for terrains. ALMOST have a DBPro like "MATRIX" except that its - you could say - made of limbs - like a checker board - each alternate color square is a different limb - one object though - I figure once I get the verts working right regardless where on this "Checker board" you want to raise/lower a x/z coord - I'll move into Poly Smoothing and I think I saw code examples for "smoothing the normals"? does something to the normals and isn't "MODEL NORMALIZATION" (Where you match scales etc. So models are all apples to apples in scale) But - Yeah - then I'm on to trying to figure out a decent Alpha Mapping Technique - and hopefully some sort of Shadow/light map or something. Ahhh...so you see - I'm running out of weekend bro - I hope someone else can help!

Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 16th Dec 2007 22:21
NO problem, i hope that someone else can jump in to save the day
You already help A LOOOOOOOOOT and I'm REALY greatfull...

lets resume the problem,

i need a function that would paste sprite's on the screen using a 2D aray? does anybody have code examples? or something?

fency federejshn
dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 17th Dec 2007 00:59 Edited at: 17th Dec 2007 12:36
In your code, remove all console related functions (eg. fstream) and use DGDK related functions instead.

Then you can use a for loop to paste images on the screen- like this:


The loop will paste sprites to cover the grid using the number of rows and columns in the array.

EDIT: I'll make a demonstration for you to download when I get back.

dbPrint ( "Sig" );
Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 17th Dec 2007 13:08
Yea but if I just paste a sprite, and for instance if that sprite is a breakable wall and i fire at it it should change in to a broken wall,

And if I change one of those sprites all of them would change cause the are pasted and inherit the images...

Shouldent it be better to just make NEW sprites?

fency federejshn
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 17th Dec 2007 16:24
Considering you can keep a Sprite ID the same and change the images at will - that's up to you - but you have choices.

Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 17th Dec 2007 19:26
I get pretty stupid results when i make separate sprites,



What is wrong with this code???

fency federejshn
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 17th Dec 2007 20:33
try adding a plus one here (a guess)

dbSprite ( (r+t)+1 , r*40, t*40 );

So you don't make a sprite ZERO. I don't think ya can (or should)

dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 17th Dec 2007 22:41
What I showed you was an example.

First, go to your Project & Directories setting in Options and link to the VC++ console app Includes directory. That should give you access to fstream.

Then store each tile using slap_the_tiles() but this time into a 2D array. Next, use the for loop to loop through the dimensions etc and "create" new sprites on the screen.

You can also create a enumerator called object_actions with { breakable, destroyable, pickup } etc and declare your array as object_actions, not int or char. Then, you can do something like this:


Now, as the player walks around on the map, you want to store the x and y of the character's position. Use a for loop to compare the (x,y) to the myArray. If the character is on a tile and presses a certain key, the wall should break.

Now that (6,5) is breakable, use if commands or switches to check if the user is behind or next to the wall.


This is if you use matrices. It painful for the head O.o

Instead use image overlapping collision detection (with layers). Much easier, simple, faster.

Do you want to learn IOCD (short for image overlapping collision detection)?

dbGamerX
P.S. for the enumerated array codes, they were just examples.

dbPrint ( "Sig" );
Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 19th Dec 2007 14:59


IT DOESENT WORK!!! it only shoes the right row and the top row???

plz help

fency federejshn
dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 20th Dec 2007 00:15
Wait what do you have working so far? Can you move the character?

dbPrint ( "Sig" );
Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 20th Dec 2007 14:56
Yea the character is moving perfectly, its just that i cant load a level!!! with the posibility of changing every sprite,,, dbPaste Sprite doesent cut it...

fency federejshn
dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 20th Dec 2007 22:11
Wait... The problem was loading the level? All this time I thought you were talking about collision. I feel dumb

Try opening fency.map using Windows Paint. Then save it as JPG. Load the sprite and layer it before the character sprite.

There are ways you can embed the JPG into the main standalone executable, so there is no way someone can steal a map (unless they use Print Screen System Request or something).

dbPrint ( "Sig" );
Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 21st Dec 2007 18:04
NO!!!

there is a proble with sticking images on the screen!!!!

If i typw for each image a new sprite it doesent paste them well, loading is no pproblem here its the actual puting the level together of small images...

fency federejshn
dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 21st Dec 2007 22:01
I'm sorry I didn't understand you before.

What do you mean by "paste them well"? It does what it's supposed to. Is it a color issue, alignment issue etc?

If you post a screen shot maybe everyone can help you, not just me (not that I'm helping you right now... I was of no use to you so far lol ).

1. Debug the program and focus the debug screen window.
2. Hold ALT and press Print Screen System Request (PrtScrnSysReq on laptops).
3. Open Paint and press CTRL + V to paste the image.
4. Save it and upload it to an image site like photobucket.com or imageshack.us.
5. Paste the direct link to the image here.

Rather than trying to describe the problem, it is easier to show it.

dbgamerX

dbPrint ( "Sig" );
Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 22nd Dec 2007 16:41



this is whats been goin on...




It doesent matter doesent have to be done MY way...

The thing is that i need good working code, in SDL there was samo OOP to work with, so i could acces the image of every sprite, I\'m having trouble with making a tile game in Dark GDK

I need to paste tiles which i can easily acces, for instance
if i paste locked door\'s 5 of them, and if i unlock one ONLY that one would open...


And that i can easyly acces every sprite that i have pasted on the screen...

fency federejshn
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 22nd Dec 2007 19:59
If these tiles are always the same width and height - and you like the GRID squared technique.... (meaning 2 dimensional - any size - works out like a sheet of Graph paper)....

I personally would make a 24 BMP file... and use colors to indicate WHICH kind of Tile. Like RED=255 = WALL, BLUE=255 = Door.
(So I can use MSPaint to make levels)

I would use code like this to read the BMP file:
(This code snip is for reading a Bitmap and Coming up with HEIGHT info based on color - but if you stick to the part that reads a bitmap and stuffs it into a memblock as a simple GRID XxZ - You might see what I mean)


Then- in that part where it says APPLY BITMAP - Paste Your Sprites - where the TYPE of Sprite is based on color, and the position is the GRIDX and GRIDY positions Times the WIDTH/Height Value per Sprite Tile (MINUS the Screen X,Y offset if you have a 2d scroller)

Now - I'm thinking you would make a little system that has another memblock - stuffed with the SPRITE ID of the Tiles in the SAME XxY as the Memblock with the colors.

So - One Memblock XxY's = SPRITE TYPE (Door, Wall)
Other Memblock XxY's has the Sprite ID - (Zero being no sprite assigned)

then if a player hits a sprite - you look in MemBlock2 to find the Sprite ID - and now you know the X,Y position of said door and by looking in the First MEmblock - you know if it is in fact a door.

Now... This isn't the FASTEST method to have in you main loop - scanning Memblocks of anysize might be a bit much - BUT - By having an array of doors, and "Stuff" you pick up - you''l be able to loop through much less stuff to see if its a door Sprite ID or a Ammo Sprite or whatever - and ALL ELSE = Wall. (Or You have to get a little fancier when different Wall TYPES act different.. Bounce bullets back - or absorb whatever)

Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 22nd Dec 2007 22:16
Dood you lost me

I Dont quite get, how should my bmp file look like? and how does it look in my game? how big do i draw the stuff in the bmp file?



can I by any chance see the holle code?? it might help...

fency federejshn
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 23rd Dec 2007 00:30
Sorry about that. I was trying to get the idea across... and I'd show you a little demo except I have been having DarkGDK compiling issues - so I removed everything - install VC2005 (full version) and I'm still having issues. I'm currently Downloading the New VC2008 Express to see if I can get that to work - if not - I'll go back fight more with my Pro VC2005.

Fency Federejshn
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location:
Posted: 23rd Dec 2007 12:40
Ok Jason hope you sort that out and give me a demo soon...

fency federejshn
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 26th Dec 2007 05:36
I did - been making progress - no demos yet... well that's not true... Look here:
http://forum.thegamecreators.com/?m=forum_view&t=120482&b=22

I know that's not a sprite / image collision example... but...

Login to post a reply

Server time is: 2024-11-17 00:06:39
Your offset time is: 2024-11-17 00:06:39