Flash and abstract classes
#1
Posted 27 December 2009 - 11:46 PM
#2
Posted 28 December 2009 - 12:41 AM
#3
Posted 28 December 2009 - 02:05 AM
#4
Posted 28 December 2009 - 07:41 AM
no way to declare variable types (not just some, all variables)
lua has a lot of strange elements:
- passing in as many parameters as you want to a function
- returning as many elements as you want
- not declaring the types of variables or... even declaring variables at all
- using functions as objects
- "object oriented" programming by using arrays
- counting from 1
- ect ect
to be honest a lot of these elements are really nice, but the whole "not declaring variables" thing is a real problem. Example; declaring variables, and then wanting to change them later on:
In C++;
int xLoc = 30; int yLoc = 15; yloc = 40; //<-------- misspelled variable, compiler error SetObjectPosition(xLoc, yLoc);
In Lua:
xLoc = 30; yLoc = 15 yloc = 40; //<-------- misspelled variable, no compiler error, //new declared variable. results in character not moving //strange bugs emerge SetObjectPosition(xLoc, yLoc);
The good news is that, while lua can develop a lot of bugs if your not careful, those bugs can generally be fixed quickly because of how rapidly you can change and test code. You don't have to recompile, restart or nothin :)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#5
Posted 28 December 2009 - 02:57 PM
#6
Posted 28 December 2009 - 03:59 PM
fireside said:
#7
Posted 28 December 2009 - 04:03 PM
I'm trying a wierd little experiment that I hope works out well. It works off the principle that a "game" can be basicly described as a series of interactions between various objects. Actors are assigned their own "behavior scripts" that are kept in lua. If you work with shaders a lot, it is actually a very similar concept... just with AI and actions instead of graphics.
There's also "interaction scripts" which are the same thing, but take 2 actors types as parameters and there you can define how those 2 types of actors deal with eachother. During the game update, it goes something like:
for every object x
for every object y
RunInteractionScriptOf(Xtype)And(Ytype)(x, y);
Of course there is other code to keep scripts from repeating twice, stop unrelated actors from calling interactions, methods for instant indexing (for speed purposes).
And of course, lua is fast, but only as fast as scripting languages go. I also set up a system where I can create a carbon copy of every script written in lua and put it in C++. To switch out the scripts, all I have to do is specify that the object will be running a script in CPP instead of in lua. It's about a 20 second process all in all.
I'm still anxious to see how all this works in the end.
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#8
Posted 28 December 2009 - 05:25 PM
I was excited about LUA until I realized how much of a pain in the butt it can be with multithreaded applications. Debugging them can also be a nightmere at times.
#9
Posted 28 December 2009 - 05:30 PM
TheNut said:
Is it a nightmare if you're running lua on a single thread (while other things like physics) are running on a seperate thread? Or how about if lua scripting was one of the last things you did in the program and the first half (intensive engine updates) was carried out with multithreading and the second half (lua) was a single thread?
Btw, I'm making it a point to write it like "Lua" and not "LUA". The creators apparently really hate it when people write it like that. It's not an acronym ;)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#10
Posted 28 December 2009 - 05:33 PM
Quote
What's kind of sad or funny, depending how you look at it, is you go to these sites and someone shows the most convoluted scheme imaginable to support something that the language doesn't. See you can do it! Sure, bud. I'll just try that out right now.
Really, though, I'm not into that heavy about OO or anything. I just want to put all similar code in a base class, differential code in an extended, put them in a container and call the same function like update or something, but it does it's own thing depending on the extended class. Apparently I can do that with the override keyword. The containers aren't fussy about type so the abstract class isn't as important, you just leave an empty function in the base class. Had me worried for a while there. I was just "What do I do now?"
I haven't used Flex. I bought Flash because I plan on using video like things in this game I want to do. I hate it in some ways but the whole online game thing is pretty cool, especially with Flash or Flex because of all the portals.
Quote
Let us know how it works out. Sounds like a good experience, anyway. I would think that the other party will start asking for all kinds of things you didn't anticipate. I don't envy anyone that writes an engine that other people use.
#11
Posted 28 December 2009 - 07:10 PM
I am kind of looking into possibly learning it.
#include <arcade>
#include <computer>
#include <drinks>
#include <hardware/high_end>
#include <snacks>
#pragma <responisiblities>
...........
#12
Posted 29 December 2009 - 02:02 AM
#13
Posted 29 December 2009 - 05:03 AM
public interface IScene {
function load(gfx:Renderer):void;
function unload(gfx:Renderer):void;
function onKeyboard(evt:KeyboardEvent):void;
function onMouse(evt:MouseEvent):void;
function onUpdate():void;
}
public class MainScene implements IScene {
function load(gfx:Renderer):void{}
function unload(gfx:Renderer):void{}
function onKeyboard(evt:KeyboardEvent):void{}
function onMouse(evt:MouseEvent):void{}
function onUpdate():void{}
}
#14
Posted 30 December 2009 - 03:16 PM
starstutter said:
no way to declare variable types (not just some, all variables)
It's not that there isn't any typing, it's that Lua uses dynamic typing.
The con is you give up early, compile-time error checking for errors related to inappropriate values based on type. Some people believe that all bugs can be thought of as poorly-defined, type-related issues. Static typing can help compilers produce faster code too. And, it helps in development efficiencies because things like Intellisense being able to tell you a method wants a boolean comes from typing.
The pro is that things like Javascript's eval() function and other run-time dynamic behaviors becomes possible, or certainly easier.
There's lots on the net on static vs. dynamic typing. It's one of those pointlessly-but-hotly debated nerdy topics in software development.
#15
Posted 30 December 2009 - 06:37 PM
alphadog said:
I still am very much liking Lua overall though :)
The prototype capabilities are unbelivable.
Quote
I hope I never end up like that -_-
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#16
Posted 30 December 2009 - 08:41 PM
starstutter said:
The usual dynamicist's answer is that unit tests should take care of isolating any errors.
#17
Posted 30 December 2009 - 10:44 PM
Quote
Good point. I'll see if I can play around with that. Thanks for the example. I think AS3 will be fine, it's a matter of getting used to it. Same way with Flash. It has a lot of nice features.
#18
Posted 29 January 2010 - 05:21 AM
To use an analogy, all electronic devices generally have the same connector to plug into the wall. However, not all electronics have the same purpose. A coffee maker and a DVD player do very different things.
The problem, of course, is that the coffee maker and DVD player have different controls for turning power on and off. The coffee maker might have a switch, while the DVD player has a button. We can't implement the toggle Power function in Abstract Electronic Device because many electronics will have different controls, so we need some way to force all subclasses of Abstract Electronic Device to implement this function themselves.
#19
Posted 29 January 2010 - 06:21 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












