• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=Bathtub;38792958]So, I'm learning basic Javascript on codeacademy and I can't get this to work. [CODE]//Check if the user is ready to play confirm("Are you ready to play?") var age = prompt("What's your age?"); if (var age < 18) { console.log("You are not old enough!") } console.log("Snow White and Batman were hanging out at the bus stop, waiting to go to the shops. There was a sale on and both needed some new threads. You've never really liked Batman. You walk up to him. ") console.log("Batman glares at you.") { var userAnswer = prompt("Are you feeling lucky, punk?") }[/CODE] It tells me that I didn't create the variable "userAnswer"[/QUOTE] [CODE] console.log("Batman glares at you.") var userAnswer = prompt("Are you feeling lucky, punk?") [/CODE] Remove the brackets.
Quick Question: How big a leap would you guys say it is from Java -> Lua? I've heard that Lua is a lot easier to work with. What are the biggest differences between the languages?
[QUOTE=Elv02;38802232]Quick Question: How big a leap would you guys say it is from Java -> Lua? I've heard that Lua is a lot easier to work with. What are the biggest differences between the languages?[/QUOTE] Lua is a scripting language. It has no real concept of object oriented programming, does not get compiled, does not build applications or software, and has no enforced data types.
[QUOTE=DarkCybo7;38802280]Lua is a scripting language. It has no real concept of object oriented programming, does not get compiled, does not build applications or software, and has no enforced data types.[/QUOTE] And it's only three letters not four... The horrors! But yeah, I'd say stick with Java, or go to c# for shits n giggles.
[QUOTE=Topgamer7;38802494]And it's only three letters not four... The horrors! But yeah, I'd say stick with Java, or go to c# for shits n giggles.[/QUOTE] It's more because I want to get into mobile app development, and while I was looking at Libgdx initially, I'm not sure if it will have everything I need. Corona SDK on the other hand looks interesting. I'm just not sure how much of a change I'm in for when trying to pick up Lua. I think I'd miss the structure of objects and classes.
[QUOTE=Elv02;38802531]It's more because I want to get into mobile app development, and while I was looking at Libgdx initially, I'm not sure if it will have everything I need. Corona SDK on the other hand looks interesting. I'm just not sure how much of a change I'm in for when trying to pick up Lua. I think I'd miss the structure of objects and classes.[/QUOTE] There are objects, but they're not strictly enforced. There is no class definition or anything, you create object structures on the fly. [code] local MyObject = { } MyGlobalObject = { } MyObject.Var1 = "Hello!"; MyGlobalObject["Var1"] = "Hey"; for n = 2, 5 do MyObject["Var" . n] = "Hola"; end for k, v in pairs( MyObject ) do print( v ); end for k, v in pairs( MyGlobalObject ) do print( v ); end [/code] As I said there's no OOP though, so not deriving or hierarchies. If anything, the structures in Lua resemble more flexible C-structs. In Gmod Lua you can actually have objects have their own methods, so you can do something like Car:Drive(); but I'm not sure if this is Gmod-specific functionality that garry might have added, or if it's standard in all Lua.
[QUOTE=Elv02;38802531]It's more because I want to get into mobile app development, and while I was looking at Libgdx initially, I'm not sure if it will have everything I need. Corona SDK on the other hand looks interesting. I'm just not sure how much of a change I'm in for when trying to pick up Lua. I think I'd miss the structure of objects and classes.[/QUOTE] Ahh well if you're looking at mobile dev. You can do c++ with [URL="http://www.madewithmarmalade.com/"]Marmalade [/URL]if I'm not mistaken. Or lua with [URL="http://getmoai.com/moai-sdk.html"]Moai[/URL]/corona. (Moai is free, but last I looked at it, still needs some dusting, sanding, maybe a bit of polishing. So some tlc). What kind of mobile development do you want to do?
[QUOTE=Topgamer7;38802747]Ahh well if you're looking at mobile dev. You can do c++ with [URL="http://www.madewithmarmalade.com/"]Marmalade [/URL]if I'm not mistaken. Or lua with [URL="http://getmoai.com/moai-sdk.html"]Moai[/URL]/corona. (Moai is free, but last I looked at it, still needs some dusting, sanding, maybe a bit of polishing. So some tlc). What kind of mobile development do you want to do?[/QUOTE] Looking at 2D game development, with the end goal being an Animal Crossing like game for mobile devices.
[QUOTE=Elv02;38802821]Looking at 2D game development, with the end goal being an Animal Crossing like game for mobile devices.[/QUOTE] Alright, yeah any of those three should be good for you. Although I would like to mention that Moai has the source available so you can change it patch it w/e! (However you do have to build it the first time, and that took forever lol)
I need some help with inheritance in C++. Consider my Particle class and a derived SpawnerParticle class: [cpp] class Particle { public: // ... virtual void Update(float frametime); // ... }; class SpawnerParticle : public Particle { public: // ... void Update(float frametime); }; [/cpp] I have another class which has a list of Particles, to which I randomly add both Particles and SpawnerParticles: [cpp]std::vector<Particle> list;[/cpp] How do I change the following loop to call the correct Update function for SpawnerParticles? [cpp] for (auto i = list.begin(); i != list.end();) { Particle &p = *i; p.Update(frametime); } [/cpp]
[QUOTE=DarkCybo7;38802697]In Gmod Lua you can actually have objects have their own methods, so you can do something like Car:Drive(); but I'm not sure if this is Gmod-specific functionality that garry might have added, or if it's standard in all Lua.[/QUOTE] That is in standard Lua, but GMod Lua adds a few utility functions like a deep copy for tables.
[QUOTE=horsedrowner;38802917]I need some help with inheritance in C++. Consider my Particle class and a derived SpawnerParticle class: [cpp] class Particle { public: // ... virtual void Update(float frametime); // ... }; class SpawnerParticle : public Particle { public: // ... void Update(float frametime); }; [/cpp] I have another class which has a list of Particles, to which I randomly add both Particles and SpawnerParticles: [cpp]std::vector<Particle> list;[/cpp] How do I change the following loop to call the correct Update function for SpawnerParticles? [cpp] for (auto i = list.begin(); i != list.end();) { Particle &p = *i; p.Update(frametime); } [/cpp][/QUOTE] You should just need to add the virtual keyword to the child class, and it should override the parent function. However it will need to have the same signature (name and parameter types).
[QUOTE=horsedrowner;38802917]How do I change the following loop to call the correct Update function for SpawnerParticles? [cpp] for (auto i = list.begin(); i != list.end();) { Particle &p = *i; p.Update(frametime); } [/cpp][/QUOTE] First, change the list to store pointers to the base class ( Particle* ). You can't have a vector of a base class because you run into problems of losing data as you're actually trying to cast the derived class into the base class. Pointers and references are both fine with polymorphic classes. Then change that loop to this: [cpp] for (auto i = list.begin(); i != list.end();) { Particle* p = *i; p->Update(frametime); } [/cpp]
[QUOTE=ECrownofFire;38802980]First, change the list to store pointers to the base class ( Particle* ). You can't have a vector of a base class because you run into problems of losing data as you're actually trying to cast the derived class into the base class. Pointers and references are both fine with polymorphic classes. Then change that loop to this: [cpp] for (auto i = list.begin(); i != list.end();) { Particle* p = *i; p->Update(frametime); } [/cpp][/QUOTE] Thank you, that worked perfectly.
[QUOTE=Topgamer7;38802846]Alright, yeah any of those three should be good for you. Although I would like to mention that Moai has the source available so you can change it patch it w/e! (However you do have to build it the first time, and that took forever lol)[/QUOTE] Thanks =D One last question though, if I wanted to eventually incorporate multiplayer, would any of these be better/worse? I'm just asking because I've been put off by some frameworks that people have had major networking issues with.
I need to make something happen on an interval with C#, XNA, lets say I want to run a method every 500 miliseconds, what would be the easiest and quickest way of doing this?
[QUOTE=Staneh;38803292]I need to make something happen on an interval with C#, XNA, lets say I want to run a method every 500 miliseconds, what would be the easiest and quickest way of doing this?[/QUOTE] [URL="http://msdn.microsoft.com/en-us/library/system.timers.timer%28v=vs.100%29.aspx"]Use System.Timers.Timer.[/URL]
Yeah, I just noticed just after I asked the questions that there was that. Thanks anyways.
[QUOTE=Staneh;38803292]I need to make something happen on an interval with C#, XNA, lets say I want to run a method every 500 miliseconds, what would be the easiest and quickest way of doing this?[/QUOTE] Get the current clock time every cycle in your main while loop, set a variable for the logic you want to run off that timer, if it is greater then 500ms execute your code. [editline]12th December 2012[/editline] [QUOTE=Elv02;38803194]Thanks =D One last question though, if I wanted to eventually incorporate multiplayer, would any of these be better/worse? I'm just asking because I've been put off by some frameworks that people have had major networking issues with.[/QUOTE] No idea aha, I imagine with moai if you cant find what you need for multiplayer, you can write it yourself. [editline]12th December 2012[/editline] [QUOTE=Simspelaaja;38803858][URL="http://msdn.microsoft.com/en-us/library/system.timers.timer%28v=vs.100%29.aspx"]Use System.Timers.Timer.[/URL][/QUOTE] This works too, woo automergin.
[QUOTE=Darkwater124;38788023]Can anyone recommend me a 3D drawing framework using either Python, Lua or Javascript that works with the Raspberry Pi?[/QUOTE] Or [QUOTE=Darkwater124;38789743]And can you give me a good PyGame tutorial for 3d then? AFAIK it's meant for 2d and not 3d.[/QUOTE] Anyone?
[QUOTE=Darkwater124;38805813]Or Anyone?[/QUOTE] I've only done some basic 3d stuff in PyGame before I was like 'Fuck it! Back to OpenGL'
I don't really expect to get some good help here but worth a shot anyway. We have to do an Assignment in AI where we select this prebuilt world, and we have to code a mind for it. I chose to do this one called Speedy, where a car moves along a lane of oncoming traffic. There are 3 lanes. The car simply has to dodge oncoming cars and reach the end. I don't really know the best way to do it, quite weak at programming. Here's a link to the sample mind, it shows you some of the methods that the world has. [url]http://pastebin.com/9kFD2MBX[/url] Any help in the right direction would be much appreciated.
[QUOTE=Topgamer7;38802747]Ahh well if you're looking at mobile dev. You can do c++ with [URL="http://www.madewithmarmalade.com/"]Marmalade [/URL]if I'm not mistaken. Or lua with [URL="http://getmoai.com/moai-sdk.html"]Moai[/URL]/corona. (Moai is free, but last I looked at it, still needs some dusting, sanding, maybe a bit of polishing. So some tlc). What kind of mobile development do you want to do?[/QUOTE]You can do C++ without Marmalade on Android, just use the NDK. (its completely free, unlike Marmalade)
[QUOTE=Darkwater124;38805813]Or Anyone?[/QUOTE] You should probably use Pyglet
[QUOTE=CmdrMatthew;38811580]You can do C++ without Marmalade on Android, just use the NDK. (its completely free, unlike Marmalade)[/QUOTE] I know, but this way you can use c++ on many of the major mobile devices.
//snip
i didnt wanna make a new thread for this. should i learn one language at a time or do you think it would be beneficial to learn multiple languages at a time? im liking javascript, but i also want to learn c++ and html. i didnt know if it would be best to concentrate on javascript or if going back and forth between languages would help me fundamentally start understanding the workflow and basic ideas behind programming.
[QUOTE=yawmwen;38817441]i didnt wanna make a new thread for this. should i learn one language at a time or do you think it would be beneficial to learn multiple languages at a time? im liking javascript, but i also want to learn c++ and html. i didnt know if it would be best to concentrate on javascript or if going back and forth between languages would help me fundamentally start understanding the workflow and basic ideas behind programming.[/QUOTE] Concrete your understanding of one, then move on.
[QUOTE=Topgamer7;38812766]I know, but this way you can use c++ on many of the major mobile devices.[/QUOTE] Marmalade isn't the only option. There is Cocos-2D X, Allegro, SDL, hell even Qt. These are all cross platform.
[QUOTE=WTF Nuke;38818674]Concrete your understanding of one, then move on.[/QUOTE] This. Become solid in one language and you'll gain a depth of knowledge that actually makes it very easy to later jump between languages. Pretty much all the features of any programming language can be mapped to a feature in another language. Most of the time, the basics will remain the same or only be syntactically different, i. e. if, for, while, etc. Sometimes the cooler language features of a language don't map directly to another language, but there's still a way of getting the same functionality. For example, properties in C# can be mapped to get*() and set*() methods in Java. Another example, C-derived languages have for(i = 0; i < 10; i++) loops, but Python only has iterator-based for loops. So to do the same thing in Python, you would use the range(0, 10), which returns an iterator that iterates the values 0 through 10. This appears in python as "for i in range(0, 10):"
Sorry, you need to Log In to post a reply to this thread.