Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 81 82 [83] 84 85 ... 91

Author Topic: Programming Help Thread (For Dummies)  (Read 94238 times)

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1230 on: January 02, 2014, 11:16:37 am »

Or just goal_1.x += ((waved = !waved) ? 1.0f : -1.0f) * waveLength;
Although I don't know if that's valid in C#...

It is valid code, but it probably won't help him since he is having issues with else ifs, and that code is more difficult to read than simple if statements for most people.
I was kidding, he was already helped, cerapa put it better than I would've been able to.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

kytuzian

  • Bay Watcher
    • View Profile
    • Kytuzian - Youtube
Re: Programming Help Thread (For Dummies)
« Reply #1231 on: January 02, 2014, 02:33:03 pm »

Or just goal_1.x += ((waved = !waved) ? 1.0f : -1.0f) * waveLength;
Although I don't know if that's valid in C#...

It is valid code, but it probably won't help him since he is having issues with else ifs, and that code is more difficult to read than simple if statements for most people.
I was kidding, he was already helped, cerapa put it better than I would've been able to.

Its not a bad solution, and its probably the one I would've used though, because it is shorter and cleaner if you can read it.

Lost in Nowhere

  • Bay Watcher
  • AHAHAHAHA~!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1232 on: January 06, 2014, 11:07:10 pm »

In Java, what would be the best and/or easiest way to create a dynamic-length array or a list that the elements can be replaced in? Or am I missing something obvious that is already there?
Logged
And so I strike, like an unseen dodge ball in an echoing gymnasium!
Another book entitled Start Your Day with Extinction.
Must be the next book in the series after Start Your Day with Death.

Mephisto

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1233 on: January 06, 2014, 11:15:50 pm »

ArrayList, Vector, and likely several more.
Logged

Anvilfolk

  • Bay Watcher
  • Love! <3
    • View Profile
    • Portuguese blacksmithing forum!
Re: Programming Help Thread (For Dummies)
« Reply #1234 on: January 07, 2014, 09:35:22 am »

Yeah, make sure you get to know most of the datastructures in the java library. They're really useful :)

Lost in Nowhere

  • Bay Watcher
  • AHAHAHAHA~!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1235 on: January 07, 2014, 10:22:25 am »

Thanks!
Logged
And so I strike, like an unseen dodge ball in an echoing gymnasium!
Another book entitled Start Your Day with Extinction.
Must be the next book in the series after Start Your Day with Death.

Araph

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1236 on: January 08, 2014, 06:15:17 pm »

I have a question about classes. If I have a character in Unity that I want to move around, would it be better to have all the movement variables be in a class? Or would it be the same to just have them be in the movement script? Since any instance of the script would be controlling a single character, I don't think it'd make a difference whether or not everything is in a class.
Logged

dennislp3

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1237 on: January 08, 2014, 07:14:15 pm »

I think a class would work better when it comes to setting options for the game if you plan on having any.
Logged

Anvilfolk

  • Bay Watcher
  • Love! <3
    • View Profile
    • Portuguese blacksmithing forum!
Re: Programming Help Thread (For Dummies)
« Reply #1238 on: January 09, 2014, 10:47:24 am »

Well, a script is a class that extends from MonoBehaviour or whatever the name is.

Recent trends in game development seem to be using component-based design. Namely, if you want something that moves, you have a MovementComponent, or MovementScript. Then you can add that to anything that you want to move, independently of whether it is a character or not - so your movement isn't tied to the fact that things are characters, it's just a capability that you can add to any entity.

Thus, a character would be an entity that has movement capabilities, inventory-management capabilities,  fighting capabilities, etc. A chest would probably only have inventory-management, but no movement or fighting.

It's a very flexible system that I'm glad seems to work fairly well in Unity :)

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1239 on: January 13, 2014, 10:46:03 am »

Recent trends in game development seem to be using component-based design.
Having tried switched to composition over inheritance myself in C++, I can say that it's awesome. USE IT!
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1240 on: January 13, 2014, 11:45:56 am »

Recent trends in game development seem to be using component-based design.
Having tried switched to composition over inheritance myself in C++, I can say that it's awesome. USE IT!

I agree.  I hardly ever have any real reason to use inheritance.
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Anvilfolk

  • Bay Watcher
  • Love! <3
    • View Profile
    • Portuguese blacksmithing forum!
Re: Programming Help Thread (For Dummies)
« Reply #1241 on: January 13, 2014, 04:17:04 pm »

I'm still slightly unclear on how to make something akin to a state-machine in compositionality, which was giving me some trouble back when I had time to work on these things, but I feel that as a general switch of paradigm it's pretty amazing :)

AlleeCat

  • Bay Watcher
  • Black, the beast, descends from shadows...
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1242 on: April 20, 2014, 02:26:52 am »

So I'm having a bit of a problem with my Lua code.
Code: [Select]
if mouseX > 10 AND mouseX < 180 AND mouseY > 520 AND mouseY < 550
then love.graphics.setColor(255,255,255)
else love.graphics.setColor(255,0,0)
end
Basically, this is supposed to highlight a button when the mouse is over it. However, when I run the code, it gives me a syntax error, saying that 'then' is expected near 'AND'. Changing the code to
Code: [Select]
if mouseX > 10 AND mouseX < 180 AND mouseY > 520 AND mouseY < 550 then love.graphics.setColor(255,255,255) else love.graphics.setColor(255,0,0)returns the same error, as does
Code: [Select]
if mouseX > 10 AND mouseX < 180 AND mouseY > 520 AND mouseY < 550 then
love.graphics.setColor(255,255,255)
else love.graphics.setColor(255,0,0)
end
Surrounding the whole thing in brackets gives me a ')' expected near 'AND' error, surrounding each variable in brackets returns the first error. I really don't know what I'm doing wrong, because I have code someone else made that does the exact same thing with no errors.

Xegeth

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1243 on: April 20, 2014, 03:56:41 am »

I believe "and" is case sensitive in lua, so you need this instead:
Code: [Select]
if mouseX > 10 and mouseX < 180 and mouseY > 520 and mouseY < 550
then love.graphics.setColor(255,255,255)
else love.graphics.setColor(255,0,0)
end
Logged

AlleeCat

  • Bay Watcher
  • Black, the beast, descends from shadows...
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1244 on: April 20, 2014, 05:22:12 am »

My girlfriend (who is more familiar with Lua than I am) was telling me that it should be capitalized. Then again it could have just been sleep deprived ramblings at 3 AM.
Pages: 1 ... 81 82 [83] 84 85 ... 91