Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


OOP Help :: Getting started with iPhone dev :: Corona / LUA


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 JustAGuy   Members   -  Reputation: 160

Like
0Likes
Like

Posted 23 October 2012 - 09:14 PM

Hello Everyone,

To keep it short so I don't bore anyone with the details, I want to begin creating games as a side project for the iPhone. I am using Corona SDK with LUA as my language and framework to work with. I am not a programmer, but I work with clients every day to assist them with integrating into our APIs for our company (I work for an online payment gateway). I am familiar and comfortable with PHP and MySQL, but I have never been able to comfortably wrap my head around object oriented design.

I am asking for some help in understanding this concept and hope that some of you from the Gamedev community can assist me with some good tutorials and explanations. I believe learning a language can be easy, but learning the core competencies which help with developing the framework of the game/application is very difficult and applies to all languages. When I try to think about how I will write the code for a game, I get frustrated because I have no idea where to start.

Dazzle me, and test me, I am not afraid of low level languages if you have good targeted tutorials.

I'm just a guy - that's it. 


Sponsor:

#2 JustAGuy   Members   -  Reputation: 160

Like
0Likes
Like

Posted 25 October 2012 - 09:12 PM

Perhaps I need to be more specific. I am choosing to learn LUA first, does anyone have any good tutorials they would like to share for this language?

I'm just a guy - that's it. 


#3 jbadams   Senior Staff   -  Reputation: 19406

Like
0Likes
Like

Posted 25 October 2012 - 10:06 PM

I normally recommend "Programming in Lua" to learn the language if that helps.

#4 JustAGuy   Members   -  Reputation: 160

Like
0Likes
Like

Posted 29 October 2012 - 02:54 PM

I have been reviewing this link along with some tutorials from tutplus. I actually didn't give the programming guide on Lua's site enough of a chance before moving on, but it is actually very good.

The tutorials at tutplus below are a good flash introduction for new Lua users who are looking to use the Corona SDK for mobile development. I think getting well acquainted with the language itself is important before trying to build anything with any SDK, so I will continue my reading on lua.org.

http://mobile.tutsplus.com/series/build-an-endless-runner-game-from-scratch/

I'm just a guy - that's it. 


#5 starbasecitadel   Members   -  Reputation: 699

Like
1Likes
Like

Posted 30 October 2012 - 07:56 PM

This is a topic I've been currently spending a significant amount of time on and just today found an approach that works well for me. My code up to recently has just been procedural, to get things rolling quickly, but now that my code base has started to expand enough it was time to really organize / refactor and part of that in my case meant switching to proper OOP.

First, for general Lua OOP I evaluated many different options, from the most popular (do it yourself metatable variants) to many object libraries, both obscure, amateur, and somewhat widely used.

My short list came to these two. First is MoonScript, which precompiles ".moon" files into Lua. It is a pretty radical transformation of Lua into something more like a cross between Lua and Ruby/Python. I like the syntax and the OOP aspects; in general MoonScript code is 30% smaller than Lua (which itself is already relatively small compared to languages like C++ and Java). By small, I mean low line count and low word count for the same executable functionality. MoonScript adds many of what I'd consider missing and useful features to Lua such as x += 3 and dozens of others.

If I was using Love2D, I probably would go with MoonScript (and that's what its author mostly uses it for successfully). However, for Corona, I felt debugging was somewhat more challenging. I also didn't want to really learn a language "on top of" Lua so to speak, as when I read other Lua libraries that I'm incorporating, it's like going to a different syntax. That said it is something I am highly tempted by so was a really close second choice.

At least for now, I ended up going with "middleclass" for OOP. https://github.com/k.../README.textile

As to part of your other question, OOP design itself I'd consider somewhat language independent, and I'm not sure where to start there. The most important aspect (imo) is to make aggressive use of subclasses (aka inheritance). In other words, from a game perspective, things like: BattleDroid is a child of Robot. LongSword is a child of Weapon. KeyboardInputDatagram is a child of GameInputDatagram. GameInputDatagram is a child of EncryptedDatagram. This is definitely a paradigm shift but once you start to think in terms of objects being children of each other (instead of objects "containing" each other) it really starts to open doors to much more reusable code. It cleans up your code since you no longer see tons of complex nested if statements and that sort of thing.

A couple notes about OOP and Corona in particular. I lost a lot of time figuring out how to integrate OOP and these two methods, and here are the solutions I was able to get working.

The first is timer.performWithDelay. For this, I'll simply refer you to an article that explains the problem and solution, and an actual example from my code:

http://www.coronalab...s-and-counting/

[source lang="plain"]timer.performWithDelay( 250, function () self.thrust_timer(self) end, 0)function Thrust:thrust_timer ( ) if self.leftThrustIsPressed == 1 or self.leftThrustQueued == 1 then -- ...end[/source]




The second issue that took a lot of time for me to find a solution for ended up having a much simpler solution. That is the imageObject.addEventListener method. Without OOP, it is easy enough to use. But how do you pass in a function as an argument, that in turn can access your object instance? Here's how:

[source lang="plain"]function Thrust:initGameObjects () -- ... self.left_thrust_button.owner = self self.left_thrust_button:addEventListener("touch", self.left_thrust_button_touch)endfunction Thrust.left_thrust_button_touch ( event ) local self = event.target.owner self.leftThrustQueued = 1end[/source]


HTH

#6 RobMiracle   Members   -  Reputation: 123

Like
0Likes
Like

Posted 16 December 2012 - 08:32 PM

Corona Labs has started a new tutorial page to help people get started wtih Lua and Corona SDK.

http://www.coronalabs.com/resources/tutorials/

#7 twisttap   Members   -  Reputation: 102

Like
0Likes
Like

Posted 23 December 2012 - 08:36 PM

Alternatively to Corona SDK, you can try Gideros Mobile which is totally free (just a splash if you dont purchase) has an adapted OO style for Lua and very good and helpful cummunity. You can check it at http://www.giderosmobile.com






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS