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 / 2d Platformer(problems)

Author
Message
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 30th Jun 2010 00:04 Edited at: 30th Jun 2010 07:00
Hey, I have reasonable experience with DarkGDK commands and have been using it for a while trying to get the hang of it. I have been trying to make a basic 2d platformer but I have encountered some problems. I have been doing 2d games for a few weeks using sprites but I realized that a platformer in the DarkGDK would have to be made with textured 3d flat boxes(for scrolling and collision purposes.) Here is the code I used:

So, my problems are that the texture is displaying on the player sprite with some weird distortion around the edges and, after jumping off of the rock or, I think, double jumping, the sprite is hovering above the ground. So, please if anybody can copy and run this code and do a few tests... then if you have any ideas on how to fix it please post! Also, if anyone was trying to make a 2d platformer and this gave 'em a bit of information, I'm glad I could help.

I do only what is not required of me.
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 30th Jun 2010 07:05
So I have been trying to make a 2d game right? I've been playing around for a while and get the gist of basic 2d games, but I wanted to try a platformer/sidescroller. So I've turned to 2d Textures on 3d Objects. My problem with my game is that after the character jumps a little(up key), he is not able to touch the ground again, and its not just a sprite thing, he ends up about 4 units of the ground. Also, another little annoying thing is that the edge of the object has some wierd distortion making it not blend into the background. Here is the code and thanks for any help you can offer:


I do only what is not required of me.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 30th Jun 2010 11:05 Edited at: 30th Jun 2010 11:06
hmm...what's wrong with the topic, i see nothing

JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 30th Jun 2010 12:36
It was there. I read it last night but didn't have an answer.

Wonder what happened to it...

JTK
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 30th Jun 2010 12:47
Isocadia
15
Years of Service
User Offline
Joined: 24th Jul 2009
Location:
Posted: 30th Jun 2010 14:59
It's back xD

Zeus, it's over. I DIVIDE YOU BY...uhh. damn what was the number again?
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 30th Jun 2010 15:04
Whoever returned it, you did the right thing, stealing is never the answer no matter how tempting.

Isocadia
15
Years of Service
User Offline
Joined: 24th Jul 2009
Location:
Posted: 30th Jun 2010 16:14
But what is you steal that wat was already stolen, so you can bring it back to the rightfull owner?

Zeus, it's over. I DIVIDE YOU BY...uhh. damn what was the number again?
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 30th Jun 2010 16:41
Quote: "doing 2d games for a few weeks using sprites but I realized that a platformer in the DarkGDK would have to be made with textured 3d flat boxes(for scrolling and collision purposes.) "


Not sure about that, you can do collision and scrolling in 2D.

Quote: "So, please if anybody can copy and run this code and do a few tests... "


Can't run it without the media, maybe a couple of screen-shots would be better.

Quote: "But what is you steal that wat was already stolen, so you can bring it back to the rightfull owner?"


This could get political lol, so I wont answer that question

Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 30th Jun 2010 21:27
Oh... one thing, I edited but I have NOOB status so it took a while to return . Anyways, how would I attach the images?, I could only attach 1... just flip that one tho and you have MartialL and u can use martialR for MartialJ, and finally, just use a blue background for the background sprite and grey for the rock sprite(microsoft paint).

I do only what is not required of me.

Attachments

Login to view attachments
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 3rd Jul 2010 00:37
Please help, I've tried altering the code in several different ways and doing tests by moving around the objects but I have still yet to discover the reason why the object is staying a few units above the ground object and thus, have not been able to fix it. I would really appreciate any testing and help anyone could give me.

I do only what is not required of me.
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 7th Jul 2010 01:05
WHY WILL NOBODY HELP ME! Please, I've been at this for WEEKS! I really need someone's help! *sob*

I do only what is not required of me.
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 7th Jul 2010 15:09
OK, your recent posts never floated this thread to the top for me.
I think there may be a bug on the forum, I was not aware that you had posted again since my last post.
I will take a look and get back to you.

Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 8th Jul 2010 00:59
Since you explain your problem as a visual one then it will be best if you upload all the media.
Put it all in one folder, zip it up and then attach the folder, then I, or anyone else will be able to test it for you quite easily.

Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 8th Jul 2010 02:16
Okay then, here is all the needed media but I'm not so sure it's visual. See, even though the jumping sprite has bent legs, when I return to the walking sprite it is hovering just above the ground.

I do only what is not required of me.

Attachments

Login to view attachments
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 8th Jul 2010 05:21
Quote: "
OK, your recent posts never floated this thread to the top for me.
"


That goes for me too...

Ok, here you go. Got it working for you with some side-notes (so to speak):



There you go!

Now, for the side notes:

First off, as you'll see, I've taken the liberty of *more* properly formatting the code (indents, spacing, code-block brackets etc). I star (*) the more because formatting is a bit of a religion when it comes to programmers and their code. However, when writing code, whatever *format* you use needs to be consistant and (at least) somewhat readable. The first time I read this post, I couldn't read the code (ok, so I was a bit drunk) so I didn't pay it no-mind... Any-who... on to the next...

Now with the actual code:

As you'll note, there is no longer a "gravity" variable. Since you are handling "gravity" already within the falling state, there's no need for an extra variable (of course, this may change for you in the future)...

Also, even though I left both the "jumping" and "falling" variables in place, they are not needed. In reality, they are mutually-exclusive. The player can either be "jumping" or "falling" - but not both. Consider the following if-statements:



Of the four possibilities above, how many will actually DoSomehting()? By my count, only two - which means a single boolean value would suffice (and be easier to understand)...

Finally, with your dbObjectCollision() tests, you should probably be more specific with them... Check what happens when you fall off the side of the ground, "fly under" the ground and then press the up-key (jump) into the ground... interesting to say the least.

As for *why* your code didn't work as expected, all I can suggest is to follow your coding logic and then follow the code above. The intentions are the same, but the logic is different. I'm sorry for not better documenting the changes, but I think this will help you get going again...

Good Luck,

JTK
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 10th Jul 2010 21:55
Good stuff JTK, does that solve your problem Keto?

Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 13th Jul 2010 06:25
Umm... firstly, sorry I didn't get back to you sooner, but when I tried running the code it acts really wierdly. Firstly, there is no condition to make the sprite come back down if you hold the up key it only applies when your not holding the up key, which wouldn't happen if you were jumping. As well, the same problem persists, after a large jump it comes back down a few pixels from the ground. I suspect that my original problem stems from the fact that if it surpasses the height surpasses the jump count(jc varriable) the program thinks that either gravity or falling is turned off(in my version at least).

I do only what is not required of me.
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 13th Jul 2010 06:26
P.S. If you could explain to me how I could do this in pure 2d scrolling, collision and everything that would be really helpful.

I do only what is not required of me.
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 13th Jul 2010 06:55
Well, sorry, I tried it again and it does work except for the jumping... there is still no constraint on that but thanks anyway, I'll try to fix that on my own, but still, anything about how I can make it true 2d would be appreciated(like... ya know, mario or maple story style).

I do only what is not required of me.
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 13th Jul 2010 07:02
Sorry about the slew of posts but I keep finding new things... anyways, another small problem is that you are able to multi jump, my program covered this with a statement that said you cant jump while falling, so now I'm very confused about where to go from here, also I was *not* able to fix the jump height error, so, as you can see, I've sort of hit a wall with this so, and I'll say it again, any help would be appreciated!

I do only what is not required of me.
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 13th Jul 2010 09:18
Maybe something like this would help:

if(dbCollision(1, 2)){dbMoveObjectUp(1, (dbObjectY(1)+20)-dbObjectY(2)));}

In this case 20 is the height of the character controlled sprite... maybe this idea would work... feedback appreciated to formulate a way in which this could be implemented and where in the code.

I do only what is not required of me.
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 14th Jul 2010 00:35
Also, any suggestions about how I could make the collision expressions more specific would be appreciated... but I'll keep trying, and thanks for all the help so far!

I do only what is not required of me.
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 15th Jul 2010 22:47
So? Anybody got any ideas... frankly I'm stumped!

I do only what is not required of me.
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 17th Jul 2010 11:32
This will be my final post on this thread unless someone responds... I am completely stuck and have no Idea how to rectify this problem with my program. I would assume that many others are stumped as well, but if you have ANY ideas PLEASE post them on this thread... even if you have a completely different way of doing it, and drastically different code, PLEASE post if you have any idea at all what to do!

I do only what is not required of me.
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 17th Jul 2010 14:49 Edited at: 17th Jul 2010 15:01


This should work for you, the main changes are as follows:
1. We record our old positions so we can put the player back to where it was when we encounter a collision, this means using dbPositionObject() instead of dbMoveObject...().
2. We check collisions twice, once for x-axis and once for y-axis.
3. Introduced a gravity variable, the player is always being pulled down.

It may seem confusing at first but there were good reasons for splitting the x, y collision checks.

Hope this helps you, good luck

Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 18th Jul 2010 20:55
WOW! Thanks that worked great just needed a few tweaks to get it exactly how I wanted it. I really appreciate the help! ... why is there no party hat emote!

I do only what is not required of me.
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 19th Jul 2010 01:37
Hey guys again... I've added a bit to the program:


and it works pretty well, but I was wondering if there was any way for me to make it so that the rock and druk(monster thingy... moving sprite) don't make me stop going up while jumping. And it's okay if nobody has ideas but that is a bit crucial to the game concept... also, any way to make semi buoyant water... so that gravity will not move him down when he's about half way in. As well... is there any way to make the background of sprite truly transparent or make it so that the druk will stop when it runs into martial. Anyways thanks guys and I'll keep working on it so this is not strictly speaking urgent!

I do only what is not required of me.
Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 23rd Aug 2010 21:56
Hi guys. This code has been working great with just a few minor modifications to the core code! So I'm reviving this post to ask how exactly to adapt this code to true 2d in the dark gdk . Thanks all!

I do only what is not required of me.

Login to post a reply

Server time is: 2024-10-01 00:54:58
Your offset time is: 2024-10-01 00:54:58