[QUOTE=Fredo;45000175]I found the definition of that keep_window_open function [url=http://www.stroustrup.com/Programming/std_lib_facilities.h]here[/url] (near the bottom):
[code]inline void keep_window_open()
{
cin.clear();
cout << "Please enter a character to exit\n";
char ch;
cin >> ch;
return;
}[/code]
So there's hardly a difference between that and cin.get, at least in terms of how it prevents the window from closing.[/QUOTE]
well cool :) now i know
[CODE]public void run() {
clsMainProgram.program.console_class.printString("AI Thread started");
while(!manager.program.quit )
{
//clsMainProgram.program.console_class.printString("AI Thread");
try{
//clsMainProgram.program.console_class.printString("AI Thread 2");
if (manager.current_level != null && manager.current_level.started && manager.wait == false && clsMainProgram.program.mode == 1 && clsMainProgram.program.pause == false)
{
try{
clsMainProgram.program.console_class.printString("AI Thread 1");
for (int n = 0; n < manager.players.size(); n++) {
if (((clsPlayer) manager.players.get(n)).isAI && (!manager.client_server))
(((clsPlayer) manager.players.get(n))).update(manager);
if (!((clsPlayer) manager.players.get(n)).dead)
((clsPlayer) manager.players.get(n)).checkIfAlive(manager);
}
}catch (Exception e)
{
clsMainProgram.program.printStackTrace(e);
}
}//manager.updateAI();
}catch (ArrayIndexOutOfBoundsException e)
{
//do nothing
e.printStackTrace();
}
}
}
}[/CODE]
This thread literally doesn't execute until I go into the Eclipse and place a breakpoint into the thread. Only then does it execute. After that it spams "AI Thread 1", but until I actually stop it with a breakpoint, it prints nothing. I've verified this several times that the only thing that causes this thing to run is stopping it with a breakpoint, or suspending it. Is this literally a bug with java or eclipse?
What's the code outside of the thread doing? Does it exit before the thread has a chance to do anything? That's the only thing I can think of, though I'm not sure how a breakpoint would change anything if that is the case.
How thread-safe is that printString method?
[QUOTE=Fredo;45002322]What's the code outside of the thread doing? Does it exit before the thread has a chance to do anything? That's the only thing I can think of, though I'm not sure how a breakpoint would change anything if that is the case.
How thread-safe is that printString method?[/QUOTE]
I changed manager.program.quit to Volatile and it worked.
[CODE]print "SciFi Simulator 2015"
print " "
currentYear = 2015
userYear = input("What year is it?")
if userYear < currentYear
print "What? This is SciFi."
if userYear = currentYear
print "Real Creative."
if userYear > currentYear
"test"
raw_input ()[/CODE]
I'm trying my hand at python, why isn't this working?
[editline]4th June 2014[/editline]
the compiler is telling me that if userYear < currentYear is invalid syntax
You need a colon at the end of line for if statements.
[QUOTE=ECrownofFire;45003206]You need a colon at the end of line for if statements.[/QUOTE]
Thanks!
Hey guys game design theory question coming at you.
So I'm intending to start a new project using LOVE, which I have some experience with. I want the game to be multiplayer, by clicking "host" in-game, with the possibility of also having dedicated servers. Since I'm starting the game from scratch I was wondering if there was some good way of creating this so that I don't have to wrestle with it a few months in when I have a ton of features all 100% clientside. What's the normal approach to this? I know that in Garry's mod, for instance, there are two completely separate Lua states for server and client... I'm not sure how I would even go about that in LOVE. (maybe threads?) Anyone have experience with this?
The game would also have SP, is it reasonable to just start a local "server" and then connect to it?
Also the LOVE forums aren't helpful on this because for whatever reason I can load like 2 or 3 threads and then they just quit loading for me, they just give me a white screen...
[editline]5th June 2014[/editline]
Also how bad of an idea is it to do [b]everything[/b] in a separate thread(s), and only push what you need to render to the main thread?
I've just started learning Lua and LÖVE, and I've got stuck on something that seems completely trivial.
How can I resolve this?
[img]http://i.imgur.com/aEQLnfa.png[/img]
What do you guys recommend for a git wrapper in Linux? I've tried GitEye, but I want to know what you guys use.
Sourcetree. But only windows/mac.
I used SmartGit/Hg before: [url]http://www.syntevo.com/smartgithg/[/url]
it's free for personal use
But yeah, i'm happy with sourcetree :P (or just command line)
There is a list here: [url]http://git-scm.com/downloads/guis[/url] if you wanna find what else is available (and endorsed in some way by git :p)
[QUOTE=LimEJET;45011920]I've just started learning Lua and LÖVE, and I've got stuck on something that seems completely trivial.
How can I resolve this?
[img]http://i.imgur.com/aEQLnfa.png[/img][/QUOTE]
Worm.__index = Worm
This metamethod will cause anything with the metatable of Worm to return Worm[key] when indexed if it doesn't have that value itself.
[QUOTE=Willox;45016161]Worm.__index = Worm
This metamethod will cause anything with the metatable of Worm to return Worm[key] when indexed if it doesn't have that value itself.[/QUOTE]
Thanks!
It's incredible how versatile the metatable system is.
I think this might be an issue with the API but do you see anything wrong with this web request? It's giving me a bad request error.
Is there anything wrong with how I'm sending the data?
[code]
public string GetAuthToken(string username, string password)
{
ServicePointManager.ServerCertificateValidationCallback = (o,s,c,e) => true;
string response = null;
const string url = "http://beta.online-go.com/api/../oauth2/access_token/";
string data = "client_id=REDACTED" + "&client_secret=REDACTED" + "&grant_type=password" +
"&username=" + username + "&password=" + password;
byte[] dataBytes = Encoding.UTF8.GetBytes(data);
var req = WebRequest.CreateHttp(url);
req.KeepAlive = true;
req.Method = "POST";
req.ContentLength = dataBytes.Length;
try
{
using (var rs = req.GetRequestStream())
{
rs.Write(dataBytes, 0, dataBytes.Length);
using (var sr = new StreamReader(req.GetResponse().GetResponseStream()))
response = sr.ReadToEnd();
}
}
catch (WebException ex)
{
Console.WriteLine(new StreamReader(ex.Response.GetResponseStream()).ReadToEnd());
}
return response;
}
[/code]
I barely started out in LUA, aiming to make SWEPS for GMOD. I was wondering how to use the "WEAPON:Reload()" function*. For example, what else would I need to write to make it, whenever I press the 'Reload' button, it emits a sound?
function*-unsure if it's a function.
[QUOTE=RedCause;45033889]I barely started out in LUA, aiming to make SWEPS for GMOD. I was wondering how to use the "WEAPON:Reload()" function*. For example, what else would I need to write to make it, whenever I press the 'Reload' button, it emits a sound?
function*-unsure if it's a function.[/QUOTE]
You're probably better off posting in the Gmod Developer forum [url]http://facepunch.com/forumdisplay.php?f=65[/url]
Thanks bruh.
So this isn't really a programming question so much as it is a utilities question.
Basically, do you guys know of any decent high-level graphics libraries, preferably for Java or C#?
I have tried, on at least three separate occasions, to get a grasp on OpenGL, but graphics programming just isn't my thing - I always bugger something up, usually with matrix transformations. I've gotten to the point where I'll drop an entire idea because it requires, somewhere along the lines, doing some form of graphics programming, which (currently) means dealing with OpenGL - I just get so demotivated at the very thought, I abandon the entire idea right then and there.
All I really want is something comparable to Love 2D's graphics capabilities, though preferably object-oriented: the ability to easily draw textured rectangles with arbitrary rotations at arbitrary positions on the screen, without fussing about with matrices and translations and all the jargon involved with doing such things in openGL. Ideally, I'd like some sort of "camera" mechanism, where I can move or rotate the camera about in some arbitrary coordinate system and it'll accommodate, particularly with zooming in and out, but I could build that myself, if I had that drawing mechanic.
Really, that's all I want. A graphics library that provides a drawing method similar to [url=https://love2d.org/wiki/love.graphics.draw]love.graphics.draw( image, quad, x, y, r, sx, sy, ox, oy, kx, ky )[/url] from Love 2D, in an object-oriented language like Java or C#.
Do you guys happen to know of any such libraries, or am I out of luck?
[QUOTE=Gmod4ever;45038049]So this isn't really a programming question so much as it is a utilities question.
Basically, do you guys know of any decent high-level graphics libraries, preferably for Java or C#?
I have tried, on at least three separate occasions, to get a grasp on OpenGL, but graphics programming just isn't my thing - I always bugger something up, usually with matrix transformations. I've gotten to the point where I'll drop an entire idea because it requires, somewhere along the lines, doing some form of graphics programming, which (currently) means dealing with OpenGL - I just get so demotivated at the very thought, I abandon the entire idea right then and there.
All I really want is something comparable to Love 2D's graphics capabilities, though preferably object-oriented: the ability to easily draw textured rectangles with arbitrary rotations at arbitrary positions on the screen, without fussing about with matrices and translations and all the jargon involved with doing such things in openGL. Ideally, I'd like some sort of "camera" mechanism, where I can move or rotate the camera about in some arbitrary coordinate system and it'll accommodate, particularly with zooming in and out, but I could build that myself, if I had that drawing mechanic.
Really, that's all I want. A graphics library that provides a drawing method similar to [url=https://love2d.org/wiki/love.graphics.draw]love.graphics.draw( image, quad, x, y, r, sx, sy, ox, oy, kx, ky )[/url] from Love 2D, in an object-oriented language like Java or C#.
Do you guys happen to know of any such libraries, or am I out of luck?[/QUOTE]
Unity uses C#. Sure, it's an entire engine, but it's got what you want.
I'm creating a grid with a 2d vector that contains a class called Node, but I found out that when you call vector.resize(size,val), that it copies the value, instead of creating a new one everytime.
This is kinda annoying because in the case where you create a new object like so:
[code]nodes.resize(ySize,std::vector<Node*>(xSize,new Node()));[/code]
it shares the same node across the entire grid.
Anyone know a way around this? Preferably without going into for/while loops because it needs to be fast.
I don't think there's a way around using a loop, but you can have it create the space in the vectors for you.
[code]nodes.resize(ySize, std::vector<Node*>(xSize, NULL));
for(int y=0;y<ySize;y++)
for(int x=0;x<xSize;x++)
nodes[y][x] = new Node();[/code]
I think any method you will find to do this would use an underlying loop anyway. I don't see what the issue is though, I highly doubt iterating through the loop is going to have much impact when compared to allocating all the memory for the nodes.
[QUOTE=FalconKrunch;45038371]I'm creating a grid with a 2d vector that contains a class called Node, but I found out that when you call vector.resize(size,val), that it copies the value, instead of creating a new one everytime.
This is kinda annoying because in the case where you create a new object like so:
[code]nodes.resize(ySize,std::vector<Node*>(xSize,new Node()));[/code]
it shares the same node across the entire grid.
Anyone know a way around this? Preferably without going into for/while loops because it needs to be fast.[/QUOTE]
1. Stop using raw pointers in C++.
2. There is no way to avoid using a loop here. And besides that, the memory allocation is going to [B]by far[/B] be the most expensive part of it.
Tomorrow me and my school group will have to run and explain a bunch of codes on c++ about what we learned along the semester, while keeping them as minimalistic as possible, so me and another guy were supposed to write a code about input/output on files and STL, I did my part but I got no word from him and it's for tomorrow, is there any concept about STL simple enough to be used in here?
[code]#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string text;
cout<<"Insert text for the file:";
cin>>text;
fstream textfile;
textfile.open("texto.txt");
textfile<<text;
textfile.close();
cin.get();
return 0;
}[/code]
It's really basic but the rest of my group said our teacher will most likely accept this much about iostream and fstream.
E: I can't even think of any way to make it better due to freaking out at the last minute work.
Maybe read a file and store the lines in a vector?
[QUOTE=Gmod4ever;45038049]So this isn't really a programming question so much as it is a utilities question.
Basically, do you guys know of any decent high-level graphics libraries, preferably for Java or C#?
I have tried, on at least three separate occasions, to get a grasp on OpenGL, but graphics programming just isn't my thing - I always bugger something up, usually with matrix transformations. I've gotten to the point where I'll drop an entire idea because it requires, somewhere along the lines, doing some form of graphics programming, which (currently) means dealing with OpenGL - I just get so demotivated at the very thought, I abandon the entire idea right then and there.
All I really want is something comparable to Love 2D's graphics capabilities, though preferably object-oriented: the ability to easily draw textured rectangles with arbitrary rotations at arbitrary positions on the screen, without fussing about with matrices and translations and all the jargon involved with doing such things in openGL. Ideally, I'd like some sort of "camera" mechanism, where I can move or rotate the camera about in some arbitrary coordinate system and it'll accommodate, particularly with zooming in and out, but I could build that myself, if I had that drawing mechanic.
Really, that's all I want. A graphics library that provides a drawing method similar to [url=https://love2d.org/wiki/love.graphics.draw]love.graphics.draw( image, quad, x, y, r, sx, sy, ox, oy, kx, ky )[/url] from Love 2D, in an object-oriented language like Java or C#.
Do you guys happen to know of any such libraries, or am I out of luck?[/QUOTE]
If you want to use C#, I'd recommend Unity. However, C++ is also an OO language, and if you're just interested in 2D, SFML is great imho.
[QUOTE=ECrownofFire;45039453]1. Stop using raw pointers in C++.
2. There is no way to avoid using a loop here. And besides that, the memory allocation is going to by far be the most expensive part of it.[/QUOTE][cpp]const size_t w = 10, h = 10;
vector<vector<unique_ptr<Node>>> v(w);
generate(begin(v), end(v), [h]
{
vector<unique_ptr<Node>> v(h);
generate(begin(v), end(v), [] { return make_unique<Node>(); });
return v;
});[/cpp]It's always cleaner (and often more efficient) to use the stuff in <algorithm>.
Note that returning a vector is quick due to the move-semantics.
[QUOTE=Asgard;45041911]If you want to use C#, I'd recommend Unity. However, C++ is also an OO language, and if you're just interested in 2D, SFML is great imho.[/QUOTE]
I feel Unity is a bit heavy for just fucking about. Really, all I need is that one method I described - I feel using an entire game engine to achieve that end is a bit overkill. :v:
As to SFML, it is (at least in my experience) as low-level as any of the other OpenGL libraries, and doesn't really accomplish what I want. Feel free to prove me wrong, though.
Plus I don't much care for C++, personally. :v:
[QUOTE=Gmod4ever;45047702]I feel Unity is a bit heavy for just fucking about. Really, all I need is that one method I described - I feel using an entire game engine to achieve that end is a bit overkill. :v:
As to SFML, it is (at least in my experience) as low-level as any of the other OpenGL libraries, and doesn't really accomplish what I want. [B]Feel free to prove me wrong, though.[/B]
Plus I don't much care for C++, personally. :v:[/QUOTE]
Challenge accepted.[cpp]// Load a texture
sf::Texture tex;
tex.loadFromFile("img.png");
// Make a sprite out of it, move and rotate it
sf::Sprite spr{tex};
spr.move(100.0f, 200.0f);
spr.rotate(90.0f);
// Make a camera and zoom in
sf::View cam;
cam.zoom(0.5f);
// Make a window and draw the sprite using the camera
sf::RenderWindow wnd;
wnd.setView(cam);
wnd.draw(spr);[/cpp]
This is SFML. It doesn't get any more OOP and simple than that IMO.
If I get a boolean statement true in a for loop, how do I make it skip that run necessarily in Java?
For example, run 1, 2, 3, and 4:
Run 1: A boolean statement was returned false
Run 2: A boolean statement was returned true mid-run, end run and go to next
Run 3: A boolean statement was returned false
Run 4: A boolean statement was returned true mid-run, end run and go to next
You get an idea. Should I just mark a boolean true and check it before I carry out the operations inside the run, and if it's true, just make an empty block of code, and place operations in the else block something like this?
[quote]
if(bool) {
// Blank
} else { // Do nothing }[/quote]
Or is it impossible?
Sorry, you need to Log In to post a reply to this thread.