Sunday, February 27, 2011

State of hmmm...

I didn't do one thing on my app over the last 1 week and 1 day. But I actually have a good reason. I was developing a new website for the bookshop that my wife and I own. We decided to buy into the e-commerce solution that the American Booksellers Association (ABA) offers to its members. The price of opting into their solution used to be too cost prohibitive for the ROI (return on investment). We're a tiny shop and our "fan base" just isn't that rabid, so once the e-commerce solution goes live I doubt we'll make that much from it, but at only $100 a month to use it, it was too inexpensive not to try. Previously, they charged a setup fee and the monthly was $250. Also, they now offer Google ebooks, so that was the primary reason I showed renewed interest.

So for the last week I've been using all of my free time to develop the website: thebookerynook.com (feel free to buy an ebook from us!).

Okay, back to the game. I abandoned my latest idea (there were buckets and witches and stuff). I still like the idea and will try to pursue it later. But as I was developing it, and had most of the game-play finished, I realized the rest of the game was too big for me at this moment. It would have been along the lines of Angry Birds. So I would need to develop 20 scenes per level with high scores and the ability to go to any already-completed level and ... well ... it was overwhelming. So I backed up and thought about a game or an app that would be "easy" to do. Where "easy" means no scoring, no levels, no worrying about getting scores up to Facebook, etc.

I did a lot of brainstorming by myself and with my wife. One idea I've toyed with before and came back to here was a maze. I assume mazes have been done and, quite frankly, I wasn't sure how to have a real maze and keep an avatar centered along the walls of the maze as a player moves it around with their finger. But the idea kept bubbling up until I married it with another idea: board games.

I've decided to build a game where the player cannot see any paths, just squares and as they travel, trying to find their, way, obstacles (ala a board game) pop up, sending them backwards, sending forwards, sending them to a different area of the board. And, you know, so on.

Sunday, February 13, 2011

Annnnnd ... action!

I have the very basics of the game finished: user can move boards (platforms) around and then pour water to melt the witch. There is definitely some refining to do. However, I need to start building the "game" - the levels/scenes/etc. So I'm going to start learning Director class. I'm still not sure of all that it does, but from reading the forum or it, it seems like a good backbone for building a game. You use it to define

I assume the name "Director" is just something that the developer (Ricardo Rauber Pereira) decided to call it. I also assume that class is specific to either Lua, Corona, or more likely, programming in general. So let me search the Great Big InterWeb to see what I kind find for the definition. Be right back.

Okay, "class" has at least two possible meanings. In OOP (object-oriented programming), a class is a category of objects. The example the Web dictionary had was a class named "shape", and in that class you have objects (along with their properties) of circles, rectangles, squares, and so on. In .NET languages (no idea what these are, has something to do with Microsoft), a class is a template.

The Director class in Corona seems more like a template, but you also define your objects. I think classes in Corona are APIs on steroids, containing functions and object descriptions.

Tuesday, February 8, 2011

Can't touch this

It's amazing how many blind alleys I enter when trying to program. Because I don't know how Lua or Corona really work I spend a lot of time and energy pursuing thoughts only to find, eventually, that I just can't get it to work that way. Spent the last two days trying to figure out how to enlarge a touch area. When I tried my game on my Android phone, the pieces were so small that it was very difficult to focus on them and drag them (or activate the bucket to pour the water). So I went to the forums and found something that might have worked: you put a larger, invisible rectangle in front of the small object. Worked great with the bucket, not so great with the boards that you drag to direct the falling water. I used display groups to link the rectangle and smaller object.

A group is like a bag and you can put your display objects into that bag so you can do things to all of the images at one time. It's a way to organize and a way to manipulate your display objects (images). Problem is, once you group them the physics engine in Corona doesn't work very well. So after I grouped the small board with the larger invisible rectangle, I could move them easily, but the water balls fell right through.

And that's when I tried different things. Tried to weld the two objects together. After wasting an hour or two I find out that you can only weld "dynamic" objects together. Well, a dynamic object reacts to the gravity of the physics engine, so the board and rectangle fall to "earth" and can't be moved to a specific area.

Then I took a detour through waste-your-time-ville and for some reason thought it would be a good idea to remove the physics from the target object. You see, I had the target object set up as a physics body so that when the water balls hit it I could have the object melt. That was working fine before, I have no idea why I decided it would be better to get rid of that. So I spent hours trying to make the code work in a way that it can't (or, more exactly, in a way that I don't know how to control it).

After a frustrating two days I find myself no further along. However, as others have said, there are no mistakes, only lessons to learn. I have learned more about coding and how Lua and how Corona work (and don't work). So that's something.

Sunday, February 6, 2011

It's just like starting over

I spent this week starting over. I scrapped everything I had because I only vaguely understood part of it and didn't understand other parts at all. I then began to recreate everything one piece at a time, using it only when I understood what the piece did.

So I'm pretty much back to where I was before I scrapped everything ... except with a much better understanding of what's going on with the code. I take that back. I'm ahead of where I was.

OH!!! I also built my "game" and ported it to my Android phone ... and the "game" works!! "Game" in quote because all that happens is: you touch the bucket and tiny balls fall out and hit their target and make it disappear. But I was very excited. Also found out that you have to port your .apk file (an Android app) to an actual web address to download it. I tried using Google Docs. I was able to download it to the phone using Google, but the phone was at a loss as to what to do with it. Now I have to figure out how to delete that file from my phone.

So, all in all, it was a pretty good week. I still have a long way to go, but the progress is good. Today I need to add multiple buckets (lives) that automatically pop back up after a bucket is used, need to add movable platforms back into the game (these divert the tiny balls), and also make the "game" able to restart itself at the end (right now after one bucket of tiny balls the game is just over and sits there).

Okay, maybe I won't get to all of that today. But it's certainly manageable by next weekend.

Monday, January 31, 2011

Pretty shiny buttons

Okay, I read a bunch of the Lua 5.1 Reference Manual, but then I found a different guide: Lua for Beginners. And it really is for beginners ... yay. This would not be of much use to a seasoned coder just looking for the differences between whatever language they know and Lua. But it works great for me. The guy who wrote it is German, so expect a stilted English, but mad props to him for putting this together (I think back in 2006).

So I started on page one and read. And read. Did some exercises. Read some more. And I understood more. After reading over half his "chapters" (they're very short), I went back to the Corona SDK website (I found out today that there's a difference between the Corona SDK and the Corona Game Something-or-other. Maybe they've been combined, I don't know, but I'll have to look into whether I'm using the correct stuff), and looked at some more sample apps. They actually made more sense. I'm starting to figure Lua out. Of course, after looking at several apps and their complexity I felt a bit discouraged because I'm still no where near being able to do some real coding. But ... baby steps. Tough for me because I'm so impatient (and easily discouraged).

Having emptied out my main.lua file, I created a button in it:

    local bucket = display.newImage( "bucket.png", 45, 20 )

Okay, actually, I displayed a PNG graphic. But it's also my button. After learning more about events today, I made the button turn on its side when you click it:


    local bucket = display.newImage( "bucket.png", 45, 20 )

    local function turnBucket( event )
    bucket:removeSelf( )
display.newImage( "bucket_pour.png", 45, 20 )
    end

    bucket:addEventListener( "touch", turnBucket )

So what did I learn today (besides this?). Well I learned that "touch" is an event name reserved by Corona to indicate that someone has touched the screen of their mobile device. Before today I didn't know if "touch" was a user-defined variable like bucket or turnBucket above. I also found where a bunch (or maybe all) of these Corona-defined events are listed.

What I didn't learn was why the word "event" is between the parens after turnBucket. The chunk of code above worked with the word "event" and without it. I shall go do some exploring and see if I can find the answer.

Second only to learning to code, is learning where all of the resources are. The more I look, however, the more confident I feel that all the information I need is out there ... I just gotta find it.

Sunday, January 30, 2011

What I don't know, Part II

This post began with: What I don't know

I find something new every day. Today, just seconds ago, it was the Corona Project Manager v2. I went ahead and bought it as it looks like it'll keep my projects organized for me.

Okay. Back to coding in Lua. Back to reading the guide. And ... wow. Lost again. I need Lua for Dummies, obviously. It was trying to explain tables. Here's their first example:


  1  a = {}     -- create a table and store its reference in `a'
  2  k = "x"
  3  a[k] = 10        -- new entry, with key="x" and value=10
  4  a[20] = "great"  -- new entry, with key=20 and value="great"
  5  print(a["x"])    --> 10
  6  k = 20
  7  print(a[k])      --> "great"
  8  a["x"] = a["x"] + 1     -- increments entry "x"
  9  print(a["x"])    --> 11

So, in line 2 because k = "x", that means that in line 3 a[k] = 10 creates a value of 10 or "x". 

Oh, wait, no it doesn't. Did I just have a minor breakthrough? Think of the table as a set of cubbies (an array?) lying flat. The name of this set of cubbies (shown in line 1) is the letter a (this is the table name). You can label each cubby whatever you want (hopefully, in reality, you're labeling them with meaningful names). So in this example, you've labelled one cubby as "x". 

For awhile I thought k (in line 2) could also be the name of a cubby, but it can't. Can cubbies only be numbers or strings? The manual says: "An associative array is an array that can be indexed not only with numbers, but also with strings or any other value of the language, except nil."

But when I tried to use a letter (no quote marks around it), as an index (the name of a cubby):

   a = {}
   a[k] = 10
   print( a[k] )

I got a runtime error saying that the table index (cubby name) was nil. However, the text quoted above might be correct and I simply don't know that "any other value of the language" does not include letters by themselves (meaning letters without quote marks around them, which is called a string).

This leads me to this question: what does line 2 do? It seems to be a pointer to the real cubby name (index), which is "x". 

If you look into cubby "x", you'll see 10, because line 3 defines that. You could also set the object in "x" with:

   a["x"] = 10

Instead, you're using the pointer named k to actually fill in the cubby named "x". Remember, k CANNOT be the name of cubby (index). So why is k there at all? I'm really not sure. My guess is that you use it when your cubbies have long names (indexes). Otherwise, I don't know why you would ever use line 2 in your code. If the cubby is named (indexed as) "BloodDonorVolunteerName", you certainly don't want to type that behemoth over and over. So you, in essence, name the name. You name a pointer as bdvn to take the place of the actual name of the cubby (index) "BloodDonorVolunteerName". 

   a = {}
   bdvn = "BloodDonorVolunteerName"
   a[bdvn] = "Bob Thompson"
   print( a[bdvn] )


Wow. That was confusing and took a lot of time for  me to figure out. I suspect someone with a mind for coding would have this figured out long before I did. That's why I dropped out of computer science, my mind was having a difficult time wrapping itself around it. But now, 30 years later, I'm trying again.

Eesh.

What I don't know

Really, every post could have this title. It's 7AM on Sunday. The chihuahua is balled up in front of the heating duct, I'm trying to wake up with a can of Coca-Cola cherry zero (why does it taste better than Diet Cherry Coke?). I'm sitting at my iMac in the dining room.

And I'm starting over.

I just made a copy of my WIP (work in progress) folder. I'm going to delete everything out of the main.lua file. That's akin to the index.html file for the Great Big InterWeb. Every Corona SDK project has to have this file, even if all is does is point to all the other files that actual do the work.

I'm starting over because I've been cludging together sample code from a bunch of different resources and I got myself dazed and confused. So I'm starting from scratch and I'm going to rebuild everything I thought I had before. I'm going to try to understand all of the code I put into the main.lua file. That will be difficult as it's still confusing to me. I still don't understand the basics of the language and I haven't stumbled across that tutorial or forum post or whatever that really breaks it down for the true beginner.  So let's start. The file is blank.

I'm starting from scratch. I've opened the Lua 5.1 Reference Manual, written by the guy (or the folks?) who developed Lua. This is the first edition. There's a second edition for sale through (damn them) Amazon. [Of course, you want to try to buy local first. ALWAYS TRY TO BUY LOCAL if you want your local community to thrive. If you don't care about your neighbors and friends and family who live near you, then by all means, just purchase from Amazon and, without a second thought, send all of your money out of state.]

Ah, I've already learned that you don't have to separate statements with a semicolon. It's optional.

Okay, I'm going to stop here because this post is getting long. Continued in Part II of What I don't know.

Saturday, January 29, 2011

Button up

Today was all about buttons. Okay, just one button. The button is a bucket. The button bucket. All I wanted was to get a bucket to tip over and have water coming from it. And you know what (after searching for something like that through the forums) I actually found some stuff that I could adapt and get it to work!

Yeah, I was pretty proud of myself until I realized that what it was doing was unrelated to the code I had put into my WIP (work in progress). So I tried to dissect what was going on. I tinkered. And tinkered. Until my tinkerer was sore. Only to find that I had screwed up my WIP file and couldn't get stuff I had put in a few days earlier to work anymore. But I pressed on and kept making things break.

Yay, me. I suspect I'll be spending all day tomorrow just trying to undo the damage I did. Right now I just don't see how I'm going to do this. The coding makes no freaking sense to me. I'm at a total loss. To say I'm bummed would be gross underestimation.

Cripes.

Thursday, January 27, 2011

Collisionectomy

Today I'm working on collisions. That's when one object hits another. The thing is, I have about 110 objects. So I have to create a table or an array, or something like that. The table will keep track of every object so that they know when to disappear. But it's not that "simple." Some of the objects will also destroy one particular object. So each time this particular object gets hit, I need to deduct points until the object reaches critical mass and implodes.

[Apple Rant] Seriously, there's no simple graphics program included with the iMac? I gotta go use my PC to do graphics and then port them over? Is that what you're telling me?

Alas, poor Yorick, I have no idea what I'm doing. I really don't know if I need tables and arrays. I found some code that did what I wanted without the table. The code worked fine on it's own, but when I tried to plug it into my existing code ... it did not work (it was suppose to make all the objects remove themselves when they came in contact with the ground).

Will try again tomorrow.

Tuesday, January 25, 2011

IDEAS!!

I started coming up with ideas for a game within moments of coming up with the idea to try to make a game. I wanted something as easy, yet addictive, as Angry Birds. If you don't know what Angry Birds is, then you probably don't have an iPhone or an Android. It's been the top downloaded game for, like, a billion years. Totally.

My first idea was about light. I wanted to turn on lights in a house. So I searched through the Corona SDK website and found ... nothing. I spent hours trying to make a "hole" in a black layer so you could see the graphic of the room below. Turns out, you can't do that. UPDATE: Turns out that now you can. Ansca added an upgrade just today that allows you to do exactly what I was trying to do. Weird timing.

Despite not being able to "turn on a light," I changed my mind about this idea because I don't think I could pull it off right now. With all of the elements I'm thinking about for this game, I'm gong to wait until I become more proficient at Corona SDK.

What then? Well, I pondered for a little while and came up with another idea that involves water. I immediately used some of the sample apps to creating something like water and within a couple of hours I had a really crude prototype working in Corona SDK.

Um, but now what?

Monday, January 24, 2011

local function what.the.hell

Okay. Calming down. And what I'm finding is that the Ansca Mobile Corona website is pretty awesome. I still have to figure out how to code, but they have sample apps that you can use to get started and see how the language works. They have a robust forum with people who seem to be quite patient and willing to help the noob (though the noobs could learn a thing or two about patience and manners).

So I'm still at a complete freakin' loss for how to do this, but I now feel a little confident that I have some help. I've been playing with a couple of the sample apps, copied in some other code I found on the site and kinda figuring stuff out. One problem (another problem) is that even the helpful forum people don't quite understand that some of us have no fracking idea how to move forward. I read a couple of tutorials that Corona users posted that were supposedly for the neophyte, but they failed to realize that they need to explain EVERYTHING. They'd put in a block of code and say: this does such-n-such. Which is nice, but I need to know how the code works and what each item does. For example:

     local background = display.newImage( "ground.png" )

So this one really is pretty self explanatory, except that what does the "local" mean? I'm not sure other than they say on the forum to use it to help with performance. Local seems to imply that it's doing its business locally. Fine. But if the "local" isn't there, how is that different? If it's not doing whatever locally anymore, just where is it doing it?

But, fine, I get it. This displays a file called "ground.png" and you've defined this image with the name "background". I assume that after display.xxx that you can put other stuff there that displays ... other stuff. And why "newImage"? Why not just display.image? Here are some more:

local function newCrate( ) --is "newCrate" a command? Or could you call it newBouncingBall if you wanted? Or do you need the "new"? Could you call it "local function crate"? Heck if I know.

local function button:tap( event ) --why the colon? Are button and tap just names or are they actual commands? Could this have been called "local function look:here( event )"?

So so confused.

Sunday, January 23, 2011

I miss my scroll wheel

Where’s the scroll wheel?!? Surely you don’t have to actually click on the scroll bar to scroll through long Web pages. Surely!?

Hi. Blogging to you from my new old iMac. For the most part, it’s a computer. I don’t like that it assumes things for you and I’d like to choose where my downloads go, but (in theory) at least I don’t have to worry about viruses. 

Anywho. I downloaded Corona SDK (the unlimited trial is free, yippee) and it does not have a GUI interface frontend or anything. It’s done entirely by programming in the Lua language. Did I just throw away a bunch of money on an iMac?

Saturday, January 22, 2011

Damn my consumerism

I bought an iMac. 

I know, I know, I can’t afford it. But I’m impulsive that way. I looked around for used Macs and stumbled across Mac “outlet” stores around Denver. The first one I went to had an old Mac, but it didn’t run Snow Leopard. Corona SDK requires 10.6, which is Snow Leopard (not to be confused with the regular Leopard ... oh, the things I’m learning about Apple computers). Those who tell you how easy they are aren’t telling you the whole truth. I’m very lucky I didn’t buy an older used Mac online. I would have assumed I could have upgraded to Snow Leopard. I couldn’t have. Some (or all?) older Macs were built as deadends. They CANNOT be upgraded, which I found out at the first outlet store I went to and asked if the older Mac could be upgraded to Snow Leopard.

So I drove to the second Mac outlet store and lo and behold, they had gotten in a shipment of iMacs from a school that were within my imaginary budget (the iMacs, not the schools). Without hemming and hawing (or hawking up a juicy) I bought one. And, yes, I’ve had some buyer’s remorse. Why am I spending this money? I probably won’t even finish making a game or app for either the iPhone or Android platforms. I’m just throwing away my goddamn money. What am I doing?? But I eat some cheddar popcorn and pretend I don’t hear that voice in spite of the fact that I’m known for giving up on projects. I get all excited and gung ho early on, but as that excitement wanes, so does my ability to stay focused. Then another project comes along and I get excited about that. A year later I suddenly remember I had been working on something awhile back, now what had that been?

Friday, January 21, 2011

It's not magically delicious ... it just isn't

I keep looking for that magically delicious program (that doesn’t run on a Mac). I’ve found out that the reason Corona SDK runs on a Mac is because it was built for iPhone (and now iPad) apps. To develop those apps you have to use Apple’s SDK (whatever it’s called), which is only available for an Apple computer. Yay. 

I tried doing some coding in Flash (AS3, I believe is the official terminology ... maybe) and am at a total loss. The coding language seems much easier to learn than the archaic ones I learned a couple of decades ago, but it’s still way beyond my knowledge base. Should I bite the bullet and get a Mac? A friend suggested I send an email out at work (as a tech writer, I work for a software house), someone might have an old Mac they’re not using anymore.

What to do. What to do.

Thursday, January 20, 2011

I almost drink some Corona

So back to Robert Nay. The article I first read didn’t have any information about what the 8th grader used to program his game. I finally read the original article written about Robert. The article I first read was just a lift of the original article, without all of the details. The original article told me about the Corona SDK created by Ansca Mobile. I have hope, again. Surely this is the GUI interface I am looking for.

Uh ... Corona SDK requires the programmer to use a Mac computer. I don’t have a Mac.

Oh, so close. But I can’t afford a Mac. I really can’t afford anything right now. I make decent money, but my wife and I own a bookshop that we started almost two years ago. The bookshop is struggling mightily and so my wife doesn’t have an income. So despite my decent money as a senior technical writer, I have zero funds. 

Wednesday, January 19, 2011

Sid Meier, you suck

This isn’t my first foray into gaming. Back around 1996 I had this really cool idea for a Civil War game. I spent months and months planning all of the details. I even designed a cover for the game. After most of the planning was complete I started approaching programmers to see if anyone was interested.

And then Sid Meier released Gettysburg

Except for one or two minor details the game-play of my game and Sid’s was identical, down to the units having flags you could click on. But at least I got to play “my” game, which is still one of my favorites. 

I have yet to forgive Sid.

Tuesday, January 18, 2011

Bubble Boy

This journey began with Robert Nay and Bubble Boy ... er, Bubble Ball. Until I read that article it hadn’t dawned on me to create my own games/apps for mobile devices. As soon as I read that article (like hundreds (thousands?) of others), I jumped right in. My first step was to find a program of some kind that allowed me to develop for mobile devices. I immediately came across Unity and a few others. I downloaded Unity and was so overwhelmed that I changed directions and decided to try Flash development, instead. Flash was less intimidating, but still, it required programming knowledge. 

Wanna know the last time I did actual programming? Well, I’m going to tell you. It was in the spring of 1983. I took Pascal (you heard me) at college (go CSU Rams!). Previous to that I had learned Basic on an Apple IIe and then Fortran using punch cards. I dropped out of computer science after the spring of 1983 and never really looked back. Today, I can find my way through HTML and have borrowed javascripts from the Web to add to my HTML pages.

And that’s my programming knowledge.

I was really hoping that, like Dreamweaver (or the like), there was a GUI program for creating games. Just click on elements to add them to the game and maybe tinker with some code every once in awhile, and presto: GAME ON!

Uh, no.