Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 472 473 [474] 475 476 ... 795

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 816310 times)

highmax28

  • Bay Watcher
  • I think this is what they call a tantrum spiral...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7095 on: March 31, 2015, 05:09:33 pm »

isNumeric and substr I don't think are part of javascript normally.  Maybe you were looking at jquery methods?
I looked it up and it said that the value turns up as a true/false, so I tried doing isNumeric(substr(username, index, index+1)) ==true && index==0, aaaaaand.... Still not working. Now the prompts don't even come up.

Seriously, this textbook is making me want to take a shotgun to it, because it claims there is a function called isLetter()
Logged
just shot him with a balistic arrow, i think he will get stuned from that >.>

"Guardian" and Sigfriend Of Necrothreat
Jee wilikers, I think Highmax is near invulnerable, must have been dunked in the river styx like achilles was.
Just make sure he wears a boot.

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7096 on: March 31, 2015, 05:14:13 pm »

You might be able to replace isNumeric by not-ing isNaN().  And there is a substr method of string. 

"hello".substr(1,2);
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7097 on: March 31, 2015, 05:15:35 pm »

Seriously, this textbook is making me want to take a shotgun to it, because it claims there is a function called isLetter()
isLetter() is a valid character function... in Java. It's not a valid one in javascript.

Are you sure you are reading a textbook about the right language you are trying to program in?
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

highmax28

  • Bay Watcher
  • I think this is what they call a tantrum spiral...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7098 on: March 31, 2015, 05:22:11 pm »

Seriously, this textbook is making me want to take a shotgun to it, because it claims there is a function called isLetter()
isLetter() is a valid character function... in Java. It's not a valid one in javascript.

Are you sure you are reading a textbook about the right language you are trying to program in?

... I think I need to go email my teacher... This textbook is ALL kinds of messed up...

First it fails to provide proper examples of javascript and uses pseudocode for everything its supposed to explain. And I'm not the only one having problems with this assignment.

I'll keep bashing it until it works... Any idea the equivalent of isNumeric() in javascript?
Logged
just shot him with a balistic arrow, i think he will get stuned from that >.>

"Guardian" and Sigfriend Of Necrothreat
Jee wilikers, I think Highmax is near invulnerable, must have been dunked in the river styx like achilles was.
Just make sure he wears a boot.

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7099 on: March 31, 2015, 05:24:49 pm »

I haven't made one myself, but you might want to check out this Stack Overflow thread.
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

highmax28

  • Bay Watcher
  • I think this is what they call a tantrum spiral...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7100 on: March 31, 2015, 05:56:41 pm »

*looks at code, looks at your example*

*realizes that its IsNumeric(<garbage>) not isNumeric(<garbage>)*

*tries, still doesn't work*

Ok, now its saying this:

Code: [Select]
ReferenceError: IsNumeric is not defined usernameValidator.html:24:0
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.

I also realized how awful my organizing of my code is...  :-[
Logged
just shot him with a balistic arrow, i think he will get stuned from that >.>

"Guardian" and Sigfriend Of Necrothreat
Jee wilikers, I think Highmax is near invulnerable, must have been dunked in the river styx like achilles was.
Just make sure he wears a boot.

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7101 on: March 31, 2015, 06:38:13 pm »

IsNumeric() stuff...

Is the assignment maybe to write your own function called IsNumeric?
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7102 on: March 31, 2015, 07:33:37 pm »

The examples are of a hypothetical IsNumeric that you add to your own code as a function. It's not a built-in so it can be called whatever you like, isNumeric, IsNumeric, IsAFrikkinNumber. Since you're meant to make this shit up yourself (since JavaScript doesn't have it by default) the name is not the issue.

highmax28

  • Bay Watcher
  • I think this is what they call a tantrum spiral...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7103 on: March 31, 2015, 08:05:19 pm »

The examples are of a hypothetical IsNumeric that you add to your own code as a function. It's not a built-in so it can be called whatever you like, isNumeric, IsNumeric, IsAFrikkinNumber. Since you're meant to make this shit up yourself (since JavaScript doesn't have it by default) the name is not the issue.
The question itself talked about it exactly being that, so... I had no idea that's what it meant. I'll start working on it then
Logged
just shot him with a balistic arrow, i think he will get stuned from that >.>

"Guardian" and Sigfriend Of Necrothreat
Jee wilikers, I think Highmax is near invulnerable, must have been dunked in the river styx like achilles was.
Just make sure he wears a boot.

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7104 on: April 01, 2015, 02:04:25 pm »

I'll just take the advice above and start my world generation with simple simplex noise, and build upon it from there. Also, the advice on trying to keep things simple. I can always come back later and make things more complex if needed.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7105 on: April 01, 2015, 03:20:16 pm »

Instead of Voronoi polygons, you can also create seed points on a 2D grid and "grow" the regions from those points until all the cells are covered. This gives you jagged borders rather than lines. If you also slow the spread down based on terrain it should give you more realistic borders at places like rivers too. This sort of grid implementation would be simpler than the polygon-based one.

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7106 on: April 01, 2015, 09:12:25 pm »

Instead of Voronoi polygons, you can also create seed points on a 2D grid and "grow" the regions from those points until all the cells are covered. This gives you jagged borders rather than lines. If you also slow the spread down based on terrain it should give you more realistic borders at places like rivers too. This sort of grid implementation would be simpler than the polygon-based one.
That is a great idea, I will about implementing that once I get there. But, I hit a small obstacle. I am having trouble understanding the math when converting from the 2d grid to the array position. I have searched around and am still having troubles with it. I made a quick illustration to explain the way I am looking at it.

Spoiler (click to show/hide)

So, If the formula is:

Code: [Select]
(y-coordinate * WidthInColumns) + x-coordinate
Then using the above example, the coordinate (3,4) would be:

Code: [Select]
(4 * 5) + 3 = 23
But, if I am counting it in the right way, that would actually be 17 in the array. So what am I doing wrong? I know that the formula must be right because multiple examples on other websites show it in the same way. So am I counting the grid in the wrong way or what?
Logged

Moghjubar

  • Bay Watcher
  • Science gets you to space.
    • View Profile
    • Demon Legend
Re: if self.isCoder(): post() #Programming Thread
« Reply #7107 on: April 01, 2015, 09:23:24 pm »

So, If the formula is:

Code: [Select]
(y-coordinate * WidthInColumns) + x-coordinate
Then using the above example, the coordinate (3,4) would be:

Code: [Select]
(4 * 5) + 3 = 23
But, if I am counting it in the right way, that would actually be 17 in the array. So what am I doing wrong? I know that the formula must be right because multiple examples on other websites show it in the same way. So am I counting the grid in the wrong way or what?

If all else fails, math from 0 (or 1).  Lets attempt to get the first element (x = 1, y = 1, since you are starting at 1 of each instead of 0 ) using that formula, which should be 0.

(1*5) + 1 = 6.   6 != 0.  Only way to make it 0 is to take both X and Y and make them both 0... which involves subtracting 1 from each. 

Apply same logic to previous example:

Code: [Select]
(3*5) +2 = 17
Logged
Steam ID
Making things in Unity
Current Project: Demon Legend
Also working on THIS! Farworld Pioneers
Mastodon

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7108 on: April 01, 2015, 10:39:05 pm »

So, If the formula is:

Code: [Select]
(y-coordinate * WidthInColumns) + x-coordinate
Then using the above example, the coordinate (3,4) would be:

Code: [Select]
(4 * 5) + 3 = 23
But, if I am counting it in the right way, that would actually be 17 in the array. So what am I doing wrong? I know that the formula must be right because multiple examples on other websites show it in the same way. So am I counting the grid in the wrong way or what?

since you are starting at 1 of each instead of 0 )

Oh, so that is what they had done. I seem to be getting stuck on the most simple things. Once again, thank you for your help Moghjubar.
Logged

Tylui

  • Bay Watcher
  • O_o
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7109 on: April 01, 2015, 11:15:38 pm »

Never feel bad about getting hung up on simple things! Simple doesn't mean obvious in a lot of cases, and you'll get better and better with every quirk you learn.
Logged
Pages: 1 ... 472 473 [474] 475 476 ... 795