[QUOTE=grlira;28624182]Getting back into SFML and I have this doubt. I want to have a dynamic data structure to hold all my drawables. For now what I have set up is a c++ list of pointers to sf::Drawble.
I want this list, as well as the RenderWindow, to be accessible by different functions across the program and not just main.
I know I can just pass a pointer around as one of the function's arguments, but I would like to avoid this, as it gets messy really fast from my experience.
So the question is, do I make these global variables, do I keep them in the main() and pass pointers around or do I do something else?[/QUOTE]
You could make a class that holds all your global variables then you would only need to pass a reference to that class and not each individual variable, not sure if thats what you meant tho
Just put extern std::list<sf::Drawable*> drawableList; in some header.
Using globals is generally not regarded as proper design though. All objects shouldn't have to know about the drawable list. In fact, only a world-class of sorts should need to know about it and handle most or all of the drawable-interactions.
[QUOTE=Richy19;28624410]You could make a class that holds all your global variables then you would only need to pass a reference to that class and not each individual variable, not sure if thats what you meant tho[/QUOTE]
I'm not sure a class holding all your global variables is really a nice way to go about it. I like the way irrlicht works with the different objects for different parts of the program, there's the device, driver and scene manager objects which you use to do various things (I think Ogre has the root object and scene manager objects too).
I think it's better to have objects aimed at certain goals than to just bung global stuff into one class, but you may have meant something like what I described anyway.
I'm making a do-not-steal program for my flash drives.
Is there a way to mount a portable TrueCrypt volume (file or partition) without administrator rights?
[editline].[/editline]
I'm upset after reading this: [url]http://www.truecrypt.org/docs/?s=non-admin-users[/url]
[code]/* GambleGui.java
*
* This class provides a GUI for
* the Gambler program. Hopefully.
*/
import java.awt.*;
import javax.swing.*;
import java.util.Scanner;
public class GambleGui extends JFrame {
public int MONEY = 500;
public int MAX_BET = 250;
public int MIN_BET = 5;
public int WIN_MAX = 1500;
public int CHOICE = 1;
Font meterFont = new Font("Arial", Font.BOLD, 36);
SpinnerModel spin = new SpinnerNumberModel(
5,
MIN_BET,
MAX_BET,
1);
public GambleGui() {
//Gui Constructor
super("Gambler");
setLayout(new FlowLayout());
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
System.out.println("Error setting native LAF.");
}
try {
JLabel moneyMeter = new JLabel("£" + Integer.toString(MONEY));
moneyMeter.setFont(meterFont);
add(moneyMeter);
} catch (Exception e) {
System.out.println("Error using the number you entered. Exception: " + e);
}
JLabel remaining = new JLabel ("remaining!");
add(remaining);
JSpinner bet = new JSpinner();
bet.setModel(spin);
add(bet);
}
}
[/code]
Fixed it! Fuck yeah.
[QUOTE=Jallen;28624701]I'm not sure a class holding all your global variables is really a nice way to go about it. I like the way irrlicht works with the different objects for different parts of the program, there's the device, driver and scene manager objects which you use to do various things (I think Ogre has the root object and scene manager objects too).
I think it's better to have objects aimed at certain goals than to just bung global stuff into one class, but you may have meant something like what I described anyway.[/QUOTE]
:S, i could have sworn we were talking about this not long ago and this is that is the way alot of you said you do it
Progress on my game, I've bindined more stuff to Lua (currently it's just a mess of demonstrating features).
Left mouse: primary fire or select unit.
Secondary fire: move unit along a path.
WASD: move unit directory.
[url]http://dl.dropbox.com/u/8617556/Distro.rar[/url]
[img]http://i.imgur.com/YBnMG.png[/img]
[QUOTE=Richy19;28625161]:S, i could have sworn we were talking about this not long ago and this is that is the way alot of you said you do it[/QUOTE]
I do use classes to hold collections of frequently used objects so I can pass them around more easily, but I don't just bung everything in one place.
I think a good balance is having several different classes for different things, but having a root object which contains them all.
-snip-
[QUOTE=Hypershadsy;28624895]I'm making a do-not-steal program for my flash drives.
Is there a way to mount a portable TrueCrypt volume (file or partition) without administrator rights?
[editline].[/editline]
I'm upset after reading this: [url]http://www.truecrypt.org/docs/?s=non-admin-users[/url][/QUOTE]
I'd mention the high-end Windows 7 editions having BitLocker, but I'm assuming you'll be using your flash drive as transfer from your computer to your school. And your school will probably be running Windows XP, which doesn't support BitLocker.
of course unless you're using your flash drive for a place other than home/school you could just stick everything in a tarball and change ".tar.gz" to ".vlm" (or something) - that'd stop pretty much everyone.
[QUOTE=Nigey Nige;28625466]Okay, here's my deal. I've got three classes.
dicegame.java is a text-based gambling game I made a while back. I'm now remaking it with a GUI. My question is: is it worth trying to integrate dicegame into GambleGui or should I just leave it and remake it from scratch?
I realise neither one would take [i]that[/i] much work, but I'm new to this and want to know which would make more sense.[/QUOTE]
[url]http://www.facepunch.com/threads/1053117-What-do-you-need-help-with-v2?p=28625472#post28625472[/url]
[QUOTE=Richy19;28625788][url]http://www.facepunch.com/threads/1053117-What-do-you-need-help-with-v2?p=28625472#post28625472[/url][/QUOTE]
herp, my bad
[QUOTE=somescripter;28625189]Progress on my game, I've bindined more stuff to Lua (currently it's just a mess of demonstrating features).
Left mouse: primary fire or select unit.
Secondary fire: move unit along a path.
WASD: move unit directory.
[url]http://dl.dropbox.com/u/8617556/Distro.rar[/url]
[img_thumb]http://i.imgur.com/YBnMG.png[/img_thumb][/QUOTE]
semicolons in lua [IMG]http://i.imgur.com/E7D9N.gif[/IMG]
also definitely not running that file since it's a widely known fact that you've harvested passwords before.
[highlight](User was banned for this post ("Rating spam" - Overv))[/highlight]
[highlight](User was banned for this post ("Extended" - Overv))[/highlight]
[QUOTE=deloc;28626021]semicolons in lua[/QUOTE]
Nothing wrong with that at all.
Edit: How is this dumb? Srsly
[QUOTE=BlkDucky;28626109]Nothing wrong with that at all.
Edit: How is this dumb? Srsly[/QUOTE]
They're not necessary, it's pretty silly to use them :/ doesn't fit the rest of the language.
[editline]15th March 2011[/editline]
Only time I'd consider using them is if I'm doing a bunch of shit on one line, using ;s for readability, but you probably shouldn't be doing all that shit on one line.
It's still legitimate code. I don't do it myself, though.
Edit: I also don't really see how it conflicts with the rest of the language but eh.
deloc, can I ask you why you seem to be rating BlkDucky's and my posts dumb no matter what the content?
[QUOTE=BlkDucky;28626516]It's still legitimate code. I don't do it myself, though.
Edit: I also don't really see how it conflicts with the rest of the language but eh.[/QUOTE]
Because no where else in the language are non-alpha numerical keywords/symbols used to indicate things like that, flow, etc.
function blah() end
not
function blah () { }
[QUOTE=Jawalt;28626714]Because no where else in the language are non-alpha numerical keywords/symbols used to indicate things like that, flow, etc.
function blah() end
not
function blah () { }[/QUOTE]
Yeah, I guess. Like I said, I don't do it myself, so I never really thought about it.
[QUOTE=Richy19;28626669]deloc, can I ask you why you seem to be rating BlkDucky's and my posts dumb no matter what the content?[/QUOTE]
Geel too, but it's kinda hard to tell because everyone seems to do that. :v:
[QUOTE=Richy19;28626669]deloc, can I ask you why you seem to be rating BlkDucky's and my posts dumb no matter what the content?[/QUOTE]
And me
The next time he pulls off this kind of stuff, he's gone for a month.
[QUOTE=Overv;28626995]The next time he pulls of this kind of stuff, he's gone for a month.[/QUOTE]
[img]http://gyazo.com/617bc1a6afcbc356e435fbeb966e3f76.png[/img]
Does this count? :rolleyes:
[QUOTE=deloc;28626021]semicolons in lua[/QUOTE]
Habbit, mainly.
[QUOTE=Bang Train;28627960]overv, hows the opengl tutorials coming along?[/QUOTE]
I haven't had time to install and configure MediaWiki yet.
Hey guys, I've been working on another masterpiece of art.
[img]http://i53.tinypic.com/2dmibfr.jpg[/img]
The goal is to name that programmer.
For example, if I were to guess the name of the short guy on the far right. I would say:
Front Far Right - Jallen
Which is correct, so don't guess that one.
Uh. Gaben. :v:
Edit: Top-left, obviously.
Notch at the top right.
Wow, took the two I only knew.
Sorry, you need to Log In to post a reply to this thread.