Author Topic: HTML5 RougeLIke  (Read 27784 times)

languard

  • Newcomer
  • Posts: 41
  • Karma: +0/-0
    • View Profile
    • Email
Re: HTML5 RougeLIke
« Reply #15 on: April 07, 2011, 07:08:34 PM »
@purestrain:  It does and doesn't.  This article does a better job explaining than I can: http://www.hunlock.com/blogs/Mastering_Javascript_Arrays#quickIDX9  The biggest problem is that the length property is 0 doing it that way, because you aren't really adding anything to the array.

purestrain

  • Rogueliker
  • ***
  • Posts: 172
  • Karma: +0/-0
    • View Profile
Re: HTML5 RougeLIke
« Reply #16 on: April 08, 2011, 06:36:25 AM »
And the problem is you don't want to add size/count functionality?  ::)

siob

  • Rogueliker
  • ***
  • Posts: 64
  • Karma: +0/-0
  • blit(brain)
    • View Profile
    • gamejs
Re: HTML5 RougeLIke
« Reply #17 on: April 08, 2011, 03:07:12 PM »
*laughs* No offense taken.  It's been 10+ years since I've worked with javascript, and I never was very heavily into the language.

What you posted is an object if I understand the language correctly, not an array. 

<cut code>

  While that appears to work in JS, it doesn't really.  Not as a true array.

what do you mean - not as a "true array"? do you miss the array functions map(), forEach() or in what way is it not behaving like an array for you?

in JS, there is no difference between an array and an object. everything is a "hash" or "associative array" (except the basic types bool, number, etc).

try this in your browser or take a peek at the manual hehe
Code: [Select]
>typeof []
"object"
>typeof {}
"object"

siob

  • Rogueliker
  • ***
  • Posts: 64
  • Karma: +0/-0
  • blit(brain)
    • View Profile
    • gamejs
Re: HTML5 RougeLIke
« Reply #18 on: April 08, 2011, 03:11:42 PM »
Arrays use the [ ] brackets for access, so it would look like this: someArray["akey"] = something.  While that appears to work in JS, it doesn't really.  Not as a true array.

ah! the brackets. you can use those for "objects" too!

var foo = {bar: 1}

can be accessed as foo['bar'] or foo.bar

languard

  • Newcomer
  • Posts: 41
  • Karma: +0/-0
    • View Profile
    • Email
Re: HTML5 RougeLIke
« Reply #19 on: April 08, 2011, 03:54:14 PM »
0.o  javascript is weird :p  At least for my C++/C# oriented mind  ;D  Hmm..random idea, write a book for game development using javascript...interesting, but need to learn the language better first :)  Wasn't aware that arrays returned as objects.  Could use typeof to generate a list of valid function names to differentiate between functions and other data types....

Be back in a bit...

languard

  • Newcomer
  • Posts: 41
  • Karma: +0/-0
    • View Profile
    • Email
Re: HTML5 RougeLIke
« Reply #20 on: April 12, 2011, 04:11:31 PM »
OK so that was more than a bit  ;D  Blog updated: goo.gl/eHMbU.  Short summery, I almost have the BSP dungeon algorithm complete.  Just need to connect the rooms and toss in some UI and it will be done.  Going to focus on getting this finished, then getting the player moving through the dungeon.

Question: Anyone know of a good rng for javascript?  My Google-foo is failing me on this.  I never trust the default rng's because they are almost never good, but I'd really rather not implement one myself.  Those things are really easy to screw up.

Edit:  I also need one so I can control the seed value.  Don't see a way of doing that with Math.random
« Last Edit: April 12, 2011, 04:23:30 PM by languard »

Hi

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 154
  • Karma: +0/-0
    • View Profile
    • Email
Re: HTML5 RougeLIke
« Reply #21 on: April 12, 2011, 04:45:51 PM »
you do indeed need to implement it yourself if you need the seed

kipar

  • Rogueliker
  • ***
  • Posts: 105
  • Karma: +0/-0
    • View Profile
    • Email
Re: HTML5 RougeLIke
« Reply #22 on: April 12, 2011, 06:22:45 PM »
I think Mersenne Twister is good enough. I haven't seen it's implemenations in JS, but the code isn't too long.

siob

  • Rogueliker
  • ***
  • Posts: 64
  • Karma: +0/-0
  • blit(brain)
    • View Profile
    • gamejs
Re: HTML5 RougeLIke
« Reply #23 on: April 13, 2011, 02:26:19 PM »
simple random number generator for JS: https://gist.github.com/917633

enjoy :)

ps.: I recently found this good & fast perlin noise generator, might fit you: https://gist.github.com/304522

languard

  • Newcomer
  • Posts: 41
  • Karma: +0/-0
    • View Profile
    • Email
Re: HTML5 RougeLIke
« Reply #24 on: April 13, 2011, 04:27:20 PM »
simple random number generator for JS: https://gist.github.com/917633

enjoy :)

ps.: I recently found this good & fast perlin noise generator, might fit you: https://gist.github.com/304522

*looks at siob funny* you do realize that 'rng' has a period of 8 numbers, right?

In all seriousness, I do thank you for try to help.  Problem is that it almost a guarantee that a home-brew rng like that is going to fail and fail hard.  Even Math.random() fails hard if you run it through the ENT test: http://www.fourmilab.ch/random/

@kipar: It is looking like I'll have to implement mersenne twister.  Need to post my implementation someplace, I'm still have trouble comprehending that one doesn't already exist  :o

languard

  • Newcomer
  • Posts: 41
  • Karma: +0/-0
    • View Profile
    • Email
Re: HTML5 RougeLIke
« Reply #25 on: April 13, 2011, 07:33:50 PM »
I knew I couldn't be the only person wanting this.  https://gist.github.com/300494  Mersenner Twist in javascript :)

siob

  • Rogueliker
  • ***
  • Posts: 64
  • Karma: +0/-0
  • blit(brain)
    • View Profile
    • gamejs
Re: HTML5 RougeLIke
« Reply #26 on: April 13, 2011, 07:46:03 PM »
simple random number generator for JS: https://gist.github.com/917633

enjoy :)

ps.: I recently found this good & fast perlin noise generator, might fit you: https://gist.github.com/304522

*looks at siob funny* you do realize that 'rng' has a period of 8 numbers, right?

In all seriousness, I do thank you for try to help.  Problem is that it almost a guarantee that a home-brew rng like that is going to fail and fail hard.  Even Math.random() fails hard if you run it through the ENT test: http://www.fourmilab.ch/random/


lol okay, i forgot rogue programmers are serious about this kind of stuff. at least the perlin noise lib i mentioned is more decent.

languard

  • Newcomer
  • Posts: 41
  • Karma: +0/-0
    • View Profile
    • Email
Re: HTML5 RougeLIke
« Reply #27 on: April 21, 2011, 09:45:25 PM »
BSP Dungeon Algorithm Implemented.  ABOUT F***ING TIME!!1!!11!  716 lines of code in the main bsp.js file.

My word but that was a Trial by Fire introduction to the JavaScript language.  I'll work on a blog post about the process, but for now if you wish to see it: goo.gl/VCr9H  The yellow lines are the rooms.  The options don't really work at them moment, so touch them at your own risk.

languard

  • Newcomer
  • Posts: 41
  • Karma: +0/-0
    • View Profile
    • Email
Re: HTML5 RougeLIke
« Reply #28 on: April 26, 2011, 03:36:48 AM »
Blog updated.  Once I get Firebug, and once I stopped fighting the dynamic nature of javascript, things went a lot smoother for me.

Now to convert the generated dungeons into playable format.  Each pixel of the current display will represent one tile in the game of course.  As I plan on using 16x16 tiles, this represents a very large play area as I have it configured.

ondras

  • Newcomer
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: HTML5 RougeLIke
« Reply #29 on: June 28, 2011, 08:55:14 AM »
First has anyone done one yet?  Currently revving up one myself to A)Get experience programming a RL before inflicting them on my students B)To learn the CANVAS tag and HTML and it's always good to see what else has been done before.

http://ondras.zarovi.cz/js-like/ :)