The Mossmouth Forums

Games => Source => Topic started by: Derek on December 25, 2009, 08:21:14 PM



Title: Spelunky Source
Post by: Derek on December 25, 2009, 08:21:14 PM
You can download the source code here (http://www.derekyu.com/games/spelunky_1_1_src.zip).  Please read the Spelunky User License (http://www.spelunkyworld.com/files/COPYING.txt) before you do anything with it (it's also included with the source).  To open the source you need the Pro version of Mark Overmars's Game Maker (http://www.yoyogames.com/make) ($25).

More information coming soon!


Title: Re: Spelunky Source
Post by: Kirby on December 25, 2009, 09:53:00 PM
It's free to edit right?

Also first post!


Title: Re: Spelunky Source
Post by: marsgreekgod on December 25, 2009, 09:53:59 PM
I couldn't post before! I was cheating out of first post!

Also yes it's free to edit, want to make an evil mod together lord kirby?


Title: Re: Spelunky Source
Post by: Derek on December 25, 2009, 10:13:58 PM
Yes, go ahead and modify and redistribute the source under the terms of the provided license - just please read the license that comes with the source first.  (I'll make a copy available online, as well.)

Also, I want to make sure people do not try to post hacked versions of the game as though they were official.  I don't think that's clear enough in the license currently.

Thanks!  Have fun. :)


Title: Re: Spelunky Source
Post by: Kegluneq on December 25, 2009, 11:13:06 PM
Oh. My. God. It finally happened.
Derek, we worship you and the ground you walk on!

I totally called it being released on X-Mas.


Title: Re: Spelunky Source
Post by: marsgreekgod on December 26, 2009, 12:00:00 AM
Thank you so much! with this kind gift I WELL MAKE HELL


Title: Re: Spelunky Source
Post by: gummybears123 on December 26, 2009, 11:42:53 AM
I look forward to it ;D


Title: Re: Spelunky Source
Post by: Bood_War on December 27, 2009, 02:03:42 PM
Is there a way to export single objects without needing a brand new .exe?


Title: Re: Spelunky Source
Post by: marsgreekgod on December 27, 2009, 02:06:05 PM
Not that I know of.


Title: Re: Spelunky Source
Post by: Bood_War on December 27, 2009, 02:12:21 PM
Hum... I made a weighted companion cube, but it's not really worth the upload...


Title: Re: Spelunky Source
Post by: marsgreekgod on December 27, 2009, 02:57:12 PM
Where is the weighted cube of companionship in game?


Title: Re: Spelunky Source
Post by: q0099 on December 27, 2009, 05:08:12 PM
Derek

Thanks for the source!

And can you tell us version of Game Maker Pro you used for development. Is Game Maker Pro 7.0 would be OK for editing?


Title: Re: Spelunky Source
Post by: Derek on December 29, 2009, 11:05:14 AM
Unfortunately, I think people are having trouble opening the source with 7.0. :( The latest version is saved in 8.0.

I'll confirm that when I get the chance.


Title: Re: Spelunky Source
Post by: marsgreekgod on December 29, 2009, 12:27:20 PM
You can't open it with 7 at all.


Title: Re: Spelunky Source
Post by: Sudonimus on December 30, 2009, 02:10:24 PM
OH MY GOD!!!
I CAN'T BELIEVE I MISSSED SEEING THIS!!

(Well, actually I can, because I never look at
the level-share spot either...)

Thanks so much Derek!

In agreement with others, we worship you!


Title: Re: Spelunky Source
Post by: gummybears123 on December 30, 2009, 03:53:47 PM
Don't forget the goats  ;)


Title: Re: Spelunky Source
Post by: Sudonimus on December 30, 2009, 06:39:14 PM
*Ahem*...
I have a wonder.

Although I haven't looked to thoroughly into it,
I found an object called "Room" (roughly),
Of course, I immediately thought it was what people
were talking about, what with the "randomly-generated
levels" and whatnot,
and when I clicked on the object,
I noticed there weren't any events for the object.

How is this possible without any events,
where's the code?

How are the levels created?


Title: Re: Spelunky Source
Post by: Kegluneq on December 30, 2009, 07:01:02 PM
By maaaagiiic!

TBH, I don't know for sure. All I have is the general theory behind it.


Title: Re: Spelunky Source
Post by: gummybears123 on December 30, 2009, 08:08:32 PM
We would all love to hear it ;D


Title: Re: Spelunky Source
Post by: Kegluneq on December 30, 2009, 08:31:08 PM
Basically, each level is divided into a bunch of rectangles.
Derek has preprogrammed a bunch of different rooms that would go into each rectangle.
The rooms are randomly assigned to the rectangles,
a path is carved from start to finish,
some more blocks are added and taken away to add variety,
and all the extra stuff is added (items, enemies, and traps)


Title: Re: Spelunky Source
Post by: marsgreekgod on December 30, 2009, 08:35:35 PM
Basically, each level is divided into a bunch of rectangles.
Derek has preprogrammed a bunch of different rooms that would go into each rectangle.
The rooms are randomly assigned to the rectangles,
a path is carved from start to finish,
some more blocks are added and taken away to add variety,
and all the extra stuff is added (items, enemies, and traps)
Problem the rooms don't fit in the blocks. the blocks just exist to tell how much is randomazed:

Idea: to test random levels, make a level 2 times as big as normal. see what happens


Title: Re: Spelunky Source
Post by: gummybears123 on December 30, 2009, 09:52:56 PM
You can make levels 2 times as big as normal?!


Title: Re: Spelunky Source
Post by: marsgreekgod on December 30, 2009, 10:00:39 PM
I can try.


Title: Re: Spelunky Source
Post by: gummybears123 on December 30, 2009, 11:10:24 PM
Then why only 2x?  Why noy like 4x or 8x?


Title: Re: Spelunky Source
Post by: marsgreekgod on December 30, 2009, 11:10:55 PM
Lag.

Also it's a test, if it goes well we can go bigger.


Title: Re: Spelunky Source
Post by: gummybears123 on December 31, 2009, 08:53:47 AM
The bigger the better... ;D


Title: Re: Spelunky Source
Post by: Sudonimus on December 31, 2009, 12:21:58 PM
Still, how are the levesls
randomly created by Game Maker?

Is there some sort of code to it?

How does he even create the object?


Title: Re: Spelunky Source
Post by: marsgreekgod on December 31, 2009, 12:25:41 PM
You asked 3 questons with very long answers. so you going to have to pick one.


Title: Re: Spelunky Source
Post by: gummybears123 on December 31, 2009, 12:49:40 PM
Why don't you just answer alll three?


Title: Re: Spelunky Source
Post by: marsgreekgod on December 31, 2009, 01:04:48 PM
My answers may very well leave more questions.

and how does he create the objects? with the create object code?


Title: Re: Spelunky Source
Post by: Svenski on January 01, 2010, 08:59:19 AM
The way level generation works is from what I see:

A 4x4 grid (different sizes for cave, jungle and ice) is made for each level, each square represents one 10x8 block mini-room inside the level. A path through the grid is made, and then different premade mini-rooms with slight random variations are placed in each square depending on the path and how the spelunker needs to get through it.

For example where the path of the level travels through a square in the 4x4 grid from left to right, a 10x8 mini-room will be placed that is known to be transversable from left to right will be placed. Squares which the spelunker does not travel through are randomly selected.

the 4x4 grid is generated in scrLevelGen and the placement of the 10x8 blocks are in scrRoomGen, you can understand what symbol means what with this :

Code:
0 -empty
1 -block (1/10 pushable)
2 -block (1/2 chance of create) (1/10 pushable)
L -Ladder
P -Ladder top
7 -spikes
4 -pushable block
9 -entrance/exit
A -altar
x -sacrificial altar
a -chest
I -idol
C -crystal idol
B -spikehead
+ -block looks like pushable
K -shopkeeper
i -shop item
W -wanted poster
k -shop sign
w -water
v -bottom water
J -fishboss
T -tree
D -damsel


Title: Re: Spelunky Source
Post by: DariusK on January 06, 2010, 02:59:41 PM
Hi Derek,

I found a minor bug in the source code. In the oPlayer1 object, in the Step Event, in the third block of code (the one that covers player damage/death), on line 148 you see the following:
Code:
obj = collision_rectangle(x-6, y-6, x+6, y+7, oSpearsLeft, 0, 0); instance_nearest(x, y, oSpearsLeft);
if (obj)
{
    ...
The instance_nearest is older deprecated code, it should be commented out like you see on line 189, so it looks like this:
Code:
obj = collision_rectangle(x-6, y-6, x+6, y+7, oSpearsLeft, 0, 0); //instance_nearest(x, y, oSpearsLeft);
if (obj)
{
    ...
Not that this *does* anything, but it should probably be cleaned up.


Title: Re: Spelunky Source
Post by: DariusK on January 06, 2010, 04:03:18 PM
And another bug. The panning on the damsel's yell has always been off for me -- when I'm standing to the right of the damsel, I hear her on the right channel, and when I'm standing to the left of the damsel, I hear her on the left channel.

Basically, in this scenario, when she yells, I hear it on the left channel.

 :spl-dude:      :spl-dams:
 :spl-bl01::spl-bl01::spl-bl01::spl-bl01::spl-bl01:

In the oDamsel step function, line 199, we see the following code:

Code:
        if (oPlayer1.x < x) SS_SetSoundPan(global.sndDamsel, -10000);
        else if (oPlayer1.x > x) SS_SetSoundPan(global.sndDamsel, 10000);
        else SS_SetSoundPan(global.sndDamsel, 0);
        playSound(global.sndDamsel);
What that says is, "if the player is to the left of the damsel, pan her yelling sound hard left." (See SS_SetSoundPan, which says at the top of the script that -10000 is full left pan.) Which is what I've observed, and it's the opposite of what we want!

Also, if this isn't the appropriate place to be posting bugs I find in the source code, please let me know!!


Title: Re: Spelunky Source
Post by: marsgreekgod on January 06, 2010, 04:04:25 PM
I think it woudl be more likely to get a hold of him in the bug area of the forum. it is the reason it exists!


Title: Re: Spelunky Source
Post by: DariusK on January 06, 2010, 04:05:33 PM
Hm, I see your point but I thought that was for bugs in the game, not in the source code? Anyway, I'll post there, thanks!


Title: Re: Spelunky Source
Post by: Sudonimus on February 28, 2010, 07:11:39 PM
People have gotten really serious with Spelunky since the Source...
Maybe if we waited a while...


Title: Re: Spelunky Source
Post by: Arucard on March 01, 2010, 06:30:29 AM
Well regarding this bug specifically, it has been reported numerous times on numerous versions. Most likely it's such a small change Derek either keeps missing it, or is more focused on fixing bigger bugs. And Darius has always been serious about Spelunky's code, he just waited until the source release to talk about it much here.


Title: Re: Spelunky Source
Post by: gummybears123 on March 01, 2010, 02:29:12 PM
People have gotten really serious with Spelunky since the Source...
Maybe if we waited a while...

Are you implying we SHOULDN'T make mods?


Title: Re: Spelunky Source
Post by: Arucard on March 01, 2010, 02:38:50 PM
It sounded to me like he was talking about the bugs, as in wait for Derek to fix them. But the previous post was put up a while back, I'm not sure if he noticed or not.


Title: Re: Spelunky Source
Post by: Bae on January 31, 2012, 03:43:15 PM
This dead thread seems like the most appropriate place to ask this

do any of these:
(http://i.imgur.com/wBTjz.png)
actually get used in the game?


Title: Re: Spelunky Source
Post by: halibabica on January 31, 2012, 03:52:05 PM
The sprites themselves don't get used, but there's a copy of them in the Panoramas or something that do.  They're added to the tops and bottoms of blocks, and disappear if you uncheck high details in the config.


Title: Re: Spelunky Source
Post by: KarjamP on May 02, 2012, 09:31:11 AM
Necro'd just to say that the price on the front page has since been inflated (and also the latest version's now 8.1).