Skip to main content

News

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Mooch

16
Of course it would? Remember, if you look at the code, "ir" and "ra" are named variables like anything else. Their names are a bit compact so they could be confusing at first, but it's no different than "red_array[iterator_red]". I hope you are not thinking it was the variable "r" smashed next to a variable called "i" and "a", because that's not how programming works.


No, I understood that. I've just tried using variables as parameters before and gotten errors.

Quote from: Radnen
Code: [Select]
    var ra = [ 0, 96, 192, 255 ];
    var ga = [ 0, 96, 192, 255 ];
    var ba = [ 0, 96, 192, 255 ];
    var row = 0;
    Link(ba).cross(ga).cross(ra).each(function(item, i) {
            if (i % 4 === 0) row++;
            Rectangle(i * 8, row * 8, 8, 8, CreateColor(item.C, item.B, item.A));
    });


ReferenceError: Link is not defined. I'm using the standard Sphere, though. I assume it works in yours and possibly TurboSphere (if that's still a thing).

That's freaking awesome, though. While grappling with this for-loop razzmatazz, I was thinking, "why isn't there just a thing that lets you essentially do nested for loops without all the rigamarole."

Quote from: Radnen
Mooch: BTW the "permutator" you are looking for is called the "set cross product". The idea is you take all the things of an array, A and pair them with all of the things of an array, B, thus creating all of the combinations. Defined as: { A × B = (x ,y) | x ∈ A, y ∈ B }


Ah, nice. Wonder if that'll be in any of my upcoming math...
17
It looked pretty awesome. The mechs at once remind me of the Robot Ride Armors from the SNES Megaman X games and the combining powers mechanic from Crystal Shards.

Can you play the main game multiplayer? That's like, 90% of the fun of Kirby games (and what makes Super Star on the SNES so good).
18

Thanks! And yeah - that game was called Tiny Trek but had been renamed to Bit Odyssey. Unfortunately, I haven't heard or seen much progress from the developer, so I think it's pretty much dead...


Aww, that sucks. It looked like a really cool game. Also, bleck. Can't call it Tiny Trek 'cause of copyright, even though "trek" is a real, normal word. Stupid. Bit Odyssey sounds cool, though.

Well, I have a portfolio site where I put a lot of my work - professional, non-professional, music-related, web design related, game related, et cetera. I need to work on it more though. :P It's all categorized so this is the music I'm showcasing on my site. (I also need to find a way to display Punch Club and Bit Odyssey at the top.)


Cool. What do you use to make your tracks? 'cause I come up with a lot of little tunes that I wanna draw out into full compositions at some point, and I was basically just thinking of doing the chiptuney-sounding ones in Famitracker, then exporting to whatever external format it'll allow.
19
Oh. You can .push arrays into an array.

Code: (javascript) [Select]
var steps = [0,80,144,255]

ColorArraySize = Math.pow(steps.length, 3);
ColorArray = new Array();
for (i = 0; i < ColorArraySize; i++){
ColorArray.push([0,0,0]);
}


That works to dynamically create the correct-sized array. I just put 0 in all the nested array slots so I could use DrawText to check that something was in there. Next step will be to permute the contents of 'steps' into ColorArray, then use that data to create Sphere Color objects that I could use when drawing the swatches.


Let me just say that you had the right idea in the original code, where you tripped up was in using a for loop for the x and y coordinates.  Rather than enumerating those, you should calculate them from your position in the palette.  How it would come together is something like this:

Code: (javascript) [Select]

var ra = [ 0, 96, 192, 255 ];
var ga = [ 0, 96, 192, 255 ];
var ba = [ 0, 96, 192, 255 ];
for (var ib = 0; ib < ba.length; ++ib) {
for (var ig = 0; ig < ga.length; ++ig) {
for (var ir = 0; ir < ra.length; ++ir) {
var x = ig * 8;
var y = ib * 8;
var i = 32 * (ir % 2);
var j = 32 * Math.floor(ir / 2);  // round toward zero
Rectangle(i + x, j + y, 8, 8, CreateColor(ra[ir], ga[ig], ba[ib]));
}
}
}
FlipScreen();


Look over that code, and see if you can figure out what it's doing and why.


I'm pouring over it now. I'm not great at math so I'm mainly trying to figure out how the i and j work. Happily, I'm also (re-)learning college math in tandem with properly learning Javascript, because I want to eventually be able to do Ben Heck-esque hacks and trig and calculus and such are prerequisites to electronics.

BTW, I did not think that something like "ra[ir]" would be accepted within the color parameter of the Rectangle function. Function parameters tend to be tempermental. I tend to have pretty bad luck cramming variables into parameters like that. Good to know it'll work.

Thanks for the code ^_^

Once I fully figure out what it's doing, I'm gonna use it to try to spurt out the swatches with my externally-created two-dimensional array. That way, I can eventually add sorting functions! Like, make it arrange by highest red-value first, or sort all the colors where blue is higher than green, or what have you.

Ooh, and I'll have to add drag-and-drop, and auto-arrange, and text display. Imma make this thing legit :)
20

Not sure what you're trying to accomplish there but in your code, you're just drawing a bunch of rectangles over each other for each (i,j), so only the final one, which happens to be white, is visible.


Ohh! Shazbots, that's right. Since the r, g and b things are nested inside the i, j parts, it's going through every single r, g and b for each i, j pair.

I'm trying to make a palette, btw. Like, a bunch of different colored squares arranged into a bigger square. Surprisingly, I could not find a "enter a bunch of step values and churn out a palette" type program online, hence my being here.

I've never appended an array before, so I think what I'll do is create code that generates a variable-length array of Sphere color objects, and then just cycle through those in the rectangle-drawing code.


I think you need to look closely at what the three for-loops for r, g, and b are doing, and re-evaluate why you chose to implement it that way. I'm myself not sure what you are trying to accomplish either, but I've never seen more than 3 for loops ever in code. 5 for loops, is what we call a code smell and it's indicative of poor logic.

Are you trying to draw a 2D field of rectangles of varying colors (IE: a palette?) Because there are far better ways. My advice: Perhaps run a for loop to create an array of colors then a 2D for loop on drawing them to screen.


Yeah, I see that now. I have a big problem, though, that I've never been able surmount. Maybe I'll learn how as I properly learn Javascript, but the problem is not being able to make a variable amount of variables.

Basically, what I wanna do with this program, is input a variable-length series of "steps." For example, [0, 63, 127, 191, 255] or perhaps [0, 15, 31, 47, ... 255], and have the program create one colored square for every possible combination of those values applied to the red, green and blue of the Rectangle function.

I can hard code values, like...

Code: (javascript) [Select]
var pal = [[0,0,0],[0,0,63],[0,0,127],...]


...but I don't know how to automate that so I can just plug in the "steps" values and have the array automatically generated. Because the thing is, the number of steps varies, so the size of the array will vary, and then there's the sticky issue of getting the correct values into the correct slots. It's dizzying.

I've googled, and I can find things like permutators where you could input, for example, [1,2,3,4] and get 1234, 1243, 1423, 1432, etc. But of course that's not what I want. No matter how many values I input, I always want them combined into every possible combination of three and only three. Because I've found other code that'd give: 1, 2, 3, 4, 11, 12, 13, 14, 21, 22, 23, 24, etc. which is also not what I want.

I'm sure it's doable and probably easy, but I haven't figured it out yet.
21
This is super-late but congrats, DaVince! Sucks about the piracy but hey, at least it didn't affect your commission, lol.

Didn't you make music for another game? It was like an Atari-style Star Trek-esque game IIRC. I remember seeing the Kickstarter some time ago.

Do you have a website for yourself as a music maker?
22
I'm learning pixel art and wanted to churn out different palettes real quick. I'm using nested for loops to draw a bunch of rectangles, and don't understand why it's not working as expected. Here's the code... (Excuse the whitespace.)

Code: (javascript) [Select]
function drawtest(){
var rows = 8;
var columns = 8;
var size = 16;
var steps = [0,80,160,240];

for (i = 0; i < rows; i++){
for (j = 0; j < columns; j++){
for (r = 0; r < steps.length; r++){
for (g = 0; g < steps.length; g++){
for (b = 0; b < steps.length; b++){
Rectangle(size+j*size,size+i*size,size,size,CreateColor(steps[r],steps[g],steps[b]));
}
}
}
}
}
}

function game(){
SetRenderScript("drawtest();");
MapEngine("m_colortest.rmp", 60);
FlipScreen();
GetKey();
}


It just draws a bunch of white rectangles, which just looks like a giant white square since there's no space inbetween them.

I don't understand why, while iterating between the for loops, it's not drawing each square a different color, given that it's correctly drawing 64 individual squares and placing them correctly (thus the i and j loops are definitely working as I expect).

Furthermore, if I manually change the Rectangle function's RBG parameters to something like (...steps[3],steps[1],steps[2]) it changes the color of the whole field of rectangles accordingly. So the steps array is capable of being accessed properly. The for loop just...isn't.

So why isn't this drawing each rectangle a different color?

(BTW, I've started reading a book on Javascript, to finally properly learn it. That's what got me interested in coding again. So I'll be learning proper theory in the coming weeks and months, so bear with me.)

(Also, I've spent over an hour toying around with the function in a dozen different ways to get the proper result to no avail; I won't tax you by showing everything I've tried.)
23
Ah, dang. I thought I remembered Z-control of images. Guess not. Alright, thanks.

Another pair of questions.

First off, is there any way to do non-rectangular Zones? Or at least, merge multiple Zones into one? The map of Magical Melody looks like this...

http://flanqer.deviantart.com/art/Harvest-Moon-Magical-Melody-map-v2-1-471226548

Notice how each property is very irregularly-shaped. I wanted to just have each property have its own Zone, because as you can see, each property has a name, and I have a little text box in the corner and I wanted to change the text to reflect what property you're hovering over.

Well, I can do that, but the zones can't have complex shapes like that, as far as I can tell.

I mean, it's a small program, I probably COULD just draw a dozen plus Zones per property and have them all run the same script and not suffer any slowdown, but I'd prefer to do something more elegant.

I've also considered making multiple identical-looking tiles, one for each Zone, and have the message display based on that. That's more labor-intensive for only slightly less of a hacked-together mess.

Second question. How the heck do I stop the cursor from going outside the game when playing in windowed mode?
24
Thanks! That is not on the Wiki, haha.

Another two quick questions, rather than make a whole 'nother topic -- how do I manage the depth of images? There's no z-coordinate in the arguments. Trying to manage the HUD.

And is there an option somewhere that I'm missing to enable the mouse cursor? Or do I just have to draw an image at the cursor location using GetMouseX/Y and images?
25
I'm slapping together a town planner/designer tool for Harvest Moon: Magical Melody. It's basically the entire map of the game, and you'll be able to place rocks and trees and grass and stuff, to plan out how you want to design your town.

Since it's a simple thing, I'm not doing anything fancy -- I'm just using AttachInput to let the user scroll around the map. The default walking speed is stone-slow, however. Is there a way to change it, or do I have to use a custom movement script? I Searched the API, Wiki and forum and couldn't find anything.
26

The var myStars declaration in Starfield.init is useless, you can safely get rid of that.


Huh? But the global declaration...
var myStars = new Array();
...only makes myStars an Array, it doesn't fill it with anything. The initialization's...
var myStars = this.number;
...makes the size of myStars whatever size you set it to in Starfield.init, so you can change the number of stars on-the-fly.

Weird, though, you're right -- when I comment it out, nothing changes, the code runs fine. I don't understand -- how does myStars know to be 32 stars in length (thanks to the "MyStarfield.init(32,2,4,8);" call in game()) without that declaration?

Second, variable scope once again plays a role in your code; you can't use myStars[ i ] after the for-loop since i will point to an "out-of-bounds" index.

As for the time comparison, I don't know what's going on there but it kind of looks like you're trying to give the star some velocity. It would be a good idea to look up some game physics tutorials for cleaner ways to do this; Fix Your Timestep and one of CodeIncomplete's JS game dev tutorials are really good starting points, though keep in mind the CodeIncomplete tutorials mainly focus on Web JS.


Ah, nice resources, thanks. Yeah, this is kind of a mess of code. I'm sort of building up towards what I want. Since I ran into problems merely displaying the stars, I got halted. The plan is obviously to have them move, eventually.


Hey Mooch, you're getting closer, here's some tips on programming cleaner:

The underscore means nothing, you don't have to use it. It's a personal convention usually indicating a privately scoped function (something very complex that we don't need to get into right now). It's not a syntax thing, it's just a thing.
Code: (javascript) [Select]

function _Star() {
}

// rename it to (make sure you rename it everywhere else too!):
function Star() {
}


Yeah, I knew it didn't have a syntactic purpose, I meant I thought he was using it as a convention to denote iterated thingies. When basing my code on others code, I typically just use their naming conventions so that I can have an easier time going back and forth from reading their code to modifying mine. I'll rename everything at the end.

Next, you can shorten this area:
Code: (javascript) [Select]

Starfield.prototype.init = function(setNum,setSpd1,setSpd2,setSpd3){
this.number = setNum;
this.speed1 = setSpd1;
this.speed2 = setSpd2;
this.speed3 = setSpd3;

if(!setNum){this.number = 108;}
if(!setSpd1){this.speed1 = 2;}
if(!setSpd2){this.speed2 = 4;}
if(!setSpd3){this.speed3 = 8;} // default values for safety's sake

this.time = GetTime();
var myStars = this.number; // Like NEO said, this does nothing. Can you guess as to why?
}


Like so:
Code: (javascript) [Select]

Starfield.prototype.init = function(setNum,setSpd1,setSpd2,setSpd3){
this.number = setNum || 108;
this.speed1 = setSpd1 || 2;
this.speed2 = setSpd2 || 4;
this.speed3 = setSpd3 || 8;

this.time = GetTime();
}


Ahh! Right! I think I knew that at one point, it looks very familiar. Pretty sure I did that on my TextTyper function to provide a default size to the text box if it's not specified. Thanks.

A problem with your iteration, like neo said is that myStars is meaningless here:
Code: (javascript) [Select]

for(var i=0; i<this.number; i++){
if (this.time < GetTime()) {
  myStars[i].y++;
  this.time = GetTime();
}
}


myStars here is treated as an array. But you have to fill that array with values. An array in JS can hold 1 or many objects.


The array is filled elsewhere, with "_Star(x,y)" objects. What that bit of code was intended to do (and realistically, I didn't expect it to be this easy, but I figured I'd try anyway) was, since each _Star in the array had an x and y value, advance the y value of each, thereby creating a star scrolling effect.

But I guess you can't use dot operators on individual elements of an Array the way I tried to there.

You fill this array in Starfield.prototype.pop(), which makes no sense to me since .pop is a function usually used for removing an item from the bottom of an array.


Er, "pop" here is short for "populate." Populate the Starfield. I didn't know that ".pop" was a thing.

That stuff can go into Starfield.prototype.init, like so:
Code: (javascript) [Select]

Starfield.prototype.init = function(setNum,setSpd1,setSpd2,setSpd3){
this.number = setNum || 108;
this.speed1 = setSpd1 || 2;
this.speed2 = setSpd2 || 4;
this.speed3 = setSpd3 || 8;

this.time = GetTime();
this.myStars = new Array(this.number); // this is the correct way to 'save' myStars

// creates this.number stars at random x/y positions
for(var i=0; i<this.number; i++){
  this.myStars[i] = new Star(Math.floor(Math.random()*MyGame.screenWidth),
  Math.floor(Math.random()*MyGame.screenHeight));
}
}


Ah okay, see, I was segregating basically every single function of Starfield into its own prototype because I wasn't 100% sure what could and couldn't be safely combined. I figured, get everything working independently first, then cram it all together.

Also that "this.myStars = new Array(this.number)" is awesome! So much neater than declaring myStars out in the open then manipulating it in .init.

Now, your exe function may look like this:
Code: (javascript) [Select]

Starfield.prototype.exe = function(){
this.time = GetTime();

for(var i=0; i<this.number; i++) {
  StarImg.blit(this.myStars[i].x,this.myStars[i].y);
}

if (this.time < GetTime()) {
  this.myStars[i].y++;
  this.time = GetTime();
}
}


It may indeed, and thanks for cleaning all that up for me. Somehow, though, I suspect that "this.myStarsI.y++;" still won't have the effect of moving the stars I was hoping for, heh. Which is okay, 'cause I'm still trying things, and since I was able to get basic physics working in my platformer, I know I'll be able to get them working here once I get back into the swing of things.

(Can't do "i" in ][ these brackets outside of a code tag or it gets interpreted as itallicize :/)

I'm very sorry to have to show you how to code this, but I implore you to compare your stuff with mine, as you can see, there are many scoping issues you still made. I can tell, you never learned from my lesson regarding the property "myStars".


Don't be! I learn best when I try, fail utterly, then have someone explain to me where I went wrong. You've been a huge help :)

Also do what NEO said and look up basic game physics and the like. Fair warning, you will need to know math. A good programmer can usually visualize the math in their heads. But if you aren't good at math, that's fine too. Use JavaScript as a sandbox to test out math and get an appreciation for it. It's the best I can say. Programming made me a better mathematician than Math courses in school.


I was doing some passable physics when I was working on my simple platformer last year, but I've been away for so long I've forgotten most of it and will have to relearn the hard way.

Thanks for all the help :)

(BTW, still reeeally weirded out by the fact that LoadImage("star.PNG") and LoadImage("star.png") are considered distinct. I've never, ever known file extensions to be case-sensitive, that seems so weird to me.)
27
Ugh, can't believe I made such a simple mistake. Well, I can actually, it's very characteristic of me. However, I've hit another snag, and this time I'm sure it's not the same rookie scope mistake as last time. Here's the whole revised code, just so you can see it, but I'll highlight the problem part after.

Code: (Javascript) [Select]


///////////
// SETUP //
///////////
function GameData(){
this.screenWidth = GetScreenWidth();
this.screenHeight = GetScreenHeight();}

var MyGame = new GameData();

///////////////////////
// STARFIELD ROUTINE //
///////////////////////
var StarImg = LoadImage("star.PNG");
// it errors if I do "star.png" for some reason,
// didn't know file extensions were case sensitive O_o
// Seriously, filenames are case-sensitive in Sphere? Really?

var myStars = new Array();

function _Star(x,y){
this.x = x;
this.y = y;}
// the above is straight from FBN's game,
// I presume the leading underscore indicates iterated thingies

function Starfield(){
//this.time = 0;
}

Starfield.prototype.init = function(setNum,setSpd1,setSpd2,setSpd3){
this.number = setNum;
this.speed1 = setSpd1;
this.speed2 = setSpd2;
this.speed3 = setSpd3;

if(!setNum){this.number = 108;}
if(!setSpd1){this.speed1 = 2;}
if(!setSpd2){this.speed2 = 4;}
if(!setSpd3){this.speed3 = 8;} // default values for safety's sake

this.time = GetTime();
var myStars = this.number;
}

Starfield.prototype.pop = function(){
// creates this.number stars at random x/y positions
for(var i=0; i<this.number; i++){
myStars[i] = new _Star(Math.floor(Math.random()*MyGame.screenWidth),
Math.floor(Math.random()*MyGame.screenHeight))
}
}

Starfield.prototype.exe = function(){
this.time = GetTime();

for(var i=0; i<this.number; i++){
StarImg.blit(myStars[i].x,myStars[i].y);
}

if (this.time < GetTime()) {
  myStars[i].y++;
  this.time = GetTime();
}
}

var MyStarfield = new Starfield();

function game(){
MyStarfield.init(32,2,4,8);
MyStarfield.pop();
while(true){MyStarfield.exe();
FlipScreen();}
}


And here's the problem...

Code: (Javascript) [Select]

Starfield.prototype.exe = function(){
this.time = GetTime();

for(var i=0; i<this.number; i++){
StarImg.blit(myStars[i].x,myStars[i].y);
}

/* if (this.time < GetTime()) {
  myStars[i].y++;
  this.time = GetTime();
} */
}


The problem is the commented-out part. If I run it as above, the code works fine, it blits a bunch of random stars on screen, yay me. If I uncomment that code, though, it spits another undefined error at me, saying myStarsI.y is undefined.

But how can that possibly, possibly be the case? Just a few lines above, StarImg.blit clearly uses myStarsI.y!

Further weirdness. If I uncomment the above and run the code, it spits an error at me almost immediately. If I change it to "if (this.time + 10 < GetTime())" it waits a split second longer before erroring. But if I ramp it up to if "(this.time + 100 < GetTime())" it never errors. I sat around for two minutes, wondering if it was somehow interpreting the 100 as 100 seconds, to no avail.

Also, if I jam the movement code in a for loop like so...

Code: (Javascript) [Select]

for(var i=0; i<this.number; i++){
if (this.time < GetTime()) {
  myStars[i].y++;
  this.time = GetTime();
}
}


Something very bizarre occurs. A single random star irregullarly, jerkily creeps downward, but then, randomly, for just a second at a time, it'll randomly move a single other star before continuing with the original star, as if the general of an army is trying to be brave and his troops are slowly, timidly advancing behind him.

I realize I'm just barking my own confusion into the ether at this point and there's not much you can say.

A pertinent question though -- if everything worked perfectly, would putting the star image blitting inside a for-loop lock up the game? Or would it happen so fast that it wouldn't interrupt gameplay? I'm always wary of for-loops for anything other than behind-the-scenes iteration.

If it's any consolation I'll likely scrap this entire page of code and start over from scratch, maybe trying to just animate a singular star exactly the way I want, and then attempting to scale up to multiple stars from there.

Honestly, since this is (supposed to be) a fast-and-dirty "just get back into the swing of things" type deal, I should just manually code variables for each individual star and avoid all this confusing array iteration for-loop stuff. And there's an elephant in the room in that I have no idea how layers work in Sphere, so I dunno what this code is gonna do once the Map Engine is drawing Player and Enemy entities on-screen. I'll have to lollop awkwardly across that bridge when I come to it.

I really ought to make a tutorial when I figure all this stuff out, if for nothing else than my own future use. I forget so much in the long dry periods between being able to code.
28
Lally-ho, everyone! You know the schpeil by now -- symptoms abating, getting back into Sphere, need some help, etc.

I'm trying to create an ultra-simple, bare-bones space shooter, just to get back into the swing of things, and I've hit a snag. I'm starting off just trying to make stars slowly, randomly scroll in the background, from the top of the screen to the bottom.

I think I've got the basic idea (although you'll be a better judge of that than I) but I can't figure out how to work Sphere's image blitting because what I'm doing is, using a for-loop to populate an array of star data objects and assign them random X and Y values, which presumably works fine. However, I can't use those X and Y values in image.blit, and when I try to put them into a variable, I get an error.

Here's my code. I took a look at FBN's puffpuff game's intro screen's starfield code to get the basic idea of what to do with my own, so I'm using some of his nomenclature.

Code: (Javascript) [Select]
///////////
// SETUP //
///////////
function GameData(){
this.screenWidth = GetScreenWidth();
this.screenHeight = GetScreenHeight();}

var MyGame = new GameData();

///////////////////////
// STARFIELD ROUTINE //
///////////////////////
var StarImg = LoadImage("star.PNG");
// it errors if I do "star.png" for some reason,
// didn't know file extensions were case sensitive O_o

function _Star(x,y){
this.x = x;
this.y = y;}
// the above is straight from FBN's game,
// I presume the leading underscore indicates iterated thingies

function Starfield(){}

Starfield.prototype.init = function(setNum,setSpd1,setSpd2,setSpd3){
this.number = setNum;
this.speed1 = setSpd1;
this.speed2 = setSpd2;
this.speed3 = setSpd3;

if(!setNum){this.number = 108;}
if(!setSpd1){this.speed1 = 2;}
if(!setSpd2){this.speed2 = 4;}
if(!setSpd3){this.speed3 = 8;} // default values for safety's sake

var myStars = new Array(this.number);

// creates this.number stars at random x/y positions
for(var i=0; i<this.number; i++){
myStars[i] = new _Star(Math.floor(Math.random()*MyGame.screenWidth),
Math.floor(Math.random()*MyGame.screenHeight))
var StarsX = myStars[i].x;
var StarsY = myStars[i].y; // this is the problem code, see below
}
}

Starfield.prototype.exe = function(){
StarImg.blit(StarsX,StarsY); // well technically THIS is the problem code
}

var MyStarfield = new Starfield();

function game(){
MyStarfield.init(108,2,4,8);
while (true){
MyStarfield.exe();}
}


As you can see, this is unfinished code -- the stars aren't moving they're just being drawn to the screen. (Theoretically.) I'm of the mind to get the code to draw static stars before I start animating.

Anyhoo, when I try to run the above, it says StarsX is not defined. I originally had 'var StarsX = myStarsi.x' inside the Starfield.prototype.exe and it told me...

"ssImageBlit - argument 0, invalid integer ... "undefined""

...and I figured since no for-iteration was being done in Starfield.exe, I must just need to move the variable declaration inside of the .init. Obviously, no such luck.

And the only reason I'm bothering with variable declaration of this kind in the first place is because originally, I tried to just do...

Code: (Javascript) [Select]
Starfield.prototype.exe = function(){
StarImg.blit(myStars[i].x,myStars[i].y);
}


And that threw the same "undefined" error in my face.

Any help? I think everything except the blitting works. I think I did the for iteration properly, and the code creates an array of stars with random x and y values. I think it's just that I can't figure out how to work with Sphere's image blitting. But feel free to disabuse me of that notion if my setup is crunked from line 1.

Danke very schoen for any help you can give :]

(edit: fixed code tag highlighting +neo)
29
Programming / Re: Mobile Apps?


Take Pixel Dungeon for example...
https://github.com/watabou/pixel-dungeon
...what, exactly, am I even looking at here? What do I click on? What do I download? It's all so confusing.


Well... you are looking at files on a virtual file structure. You can open the folders to see more files. The game is written in Java, and it's apparent that the source code is inside of src/com/watabou/pixeldungeon. The files you see that are "too small to be source code" are in fact random files, such as a readme, license, and a .gitignore which are standard files anybody would put into a basic git repository (at the root folder). So, yeah, what you are seeing is a list of files.

Source code repositories are like DropBox, right, so they are a place to put files. But it's more than that since you have a history, a "commit history" that has the changes and an explanation for each commit. The files you see on github are the latest files on that branch. The default branch is master. Git and other repositories use a tree structure to track all information. Branches of this tree can be made at any time, deleted, or merged. They can even be merged into master, which some system also call the "trunk" because like any decent tree, you gotta have a trunk.

Systems like these were made as metaphors of trees since it's easier to visualize them that way. Just like your filesystem. So that's what you see there.

Github for windows can make it really easy to get git up and running. There are plenty of git tutorials out there. Once you do have a git repo it's up to you to commit. I usually commit whenever the features I set for myself have been coded out, but some people do it daily or for every little change. It's up to you how you want to commit and sync (don't forget to sync a git repo because commits are stored locally until you push them online, this is different than say, how SVN does things (another code repository or 'subversioning' system)).


I was actually just coming to change/delete my last post, heh. I downloaded the entire thing as a zip, unzipped it and started poking around the files with Notepad++. Thanks, though.

Unfortunately, the code is not commented. At all. From the few files I poked around in, there wasn't a single comment aside from the "this is open source licensed under the GNU" boilerplate at the top of every file.

I was hoping, somewhere down the line, to use Pixel Dungeon's code as a basis to play around with a point-to-move top-down game, but there's virtually no chance I'll be able to tell how the code works just from looking at it. I can't even tell which file is the "main" file or how it runs, in a fundamental way. Like, if I take a look at the main.js file of any given Sphere project, I can get a basic idea of what it's doing and how it's doing it, but those Pixel Dungeon files...

To be fair, I'm somewhat familiar with Sphere and not at all with Java or Android, but still.

At the very least, I can change the graphics, and I should be able to change any numerical or nominal data (enemy HP and names, for example) so I could tweak things for personal use. Though the main thing I want to do is get rid of the item degredation code, heh. (watabou introduced it two updates ago and everyone hates it, but he's not backing down.)

All that's getting super ahead of myself, though. The Android Studio just finished downloading (the android.com tutorial recommends it -- funny, just December it recommended Eclipse) so I'll start following the tutorial next time I get on the computer. Right now, my goal is just to be able to follow along with that.
30
Programming / Re: Mobile Apps?
Whew, sorry to disappear there. Didn't start my studies yet, been busy. I'm gonna jump into it all now (following that android.com tutorial), and I have sort of a big question, even if it's getting ahead of myself.

What do I do with Github?

Open-source stuff is always hosted on Github, they say, "this program is open-source, here's the Github link." But the Github link typically has like, nineteen different things, and none of them are obviously labeled as "the source code," and even when they are it just downloads like, random weird files that don't actually look like anything and that I can't seem to open and that are typically so tiny I doubt they could possibly be the source to anything, anyway.

Take Pixel Dungeon for example...
https://github.com/watabou/pixel-dungeon
...what, exactly, am I even looking at here? What do I click on? What do I download? It's all so confusing.

Well, in the meantime, I'll go give that android.com tutorial a whirl.