[QUOTE=WTF Nuke;34852334]Java after C++ makes so little sense. What do I use to store an array of things? In C++ you either use vector for random access or list for double linked shit, but now people are saying either use arraylist or just a simple array or list or what jesus.[/QUOTE]
In Java, anything named *List is a class which satisfies the "List" interface. They have the same methods, but the difference is in the implementation.
An ArrayList is a List which is implemented as a growable array (called a Vector in C++, but, IMHO, that's a really stupid name), while a LinkedList is a list which is implemented as a linked list. So while you can index a LinkedList, you probably want to avoid it because it's slow.
[QUOTE=WTF Nuke;34852334]And why is this wrong:
[code]List<Integer> lists = new List<Integer>();[/code][/QUOTE]
It is wrong because List is an interface with no implementation. You need to do something like:
[code]List<Integer> lists = new ArrayList<Integer>();[/code]
[QUOTE=Topgamer7;34852918]What language? C#? You need to parse the string to an integer value, then multiply that by 100, and write it to the console.[/QUOTE]
Yeah and do i have to int = age or something sorry for loads of questions i'm new to programming.
Ah ok, thanks robo! Another quickie, what's the difference between J2SE 1.5 and JavaSE 1.7. J2SE implies that it is the second version of java, but it seems like the most up to date version is 1.7.
[editline]24th February 2012[/editline]
Oh they just renamed it nevermind.
[QUOTE=IndieGamer;34853077]Yeah and do i have to int = age or something sorry for loads of questions i'm new to programming.[/QUOTE]
It's fine.
declare another int, call it "temp" or something. then you will want to make the temp integer as 100*age.
Then output that to the console.
should look something like this
int age = 47, temp;
temp = age * 100;
Console.WriteLine("My age is: " + temp);
It's been a while since I did anything in c# so the writeline syntax could be wrong.
[QUOTE=Topgamer7;34853301]It's fine.
declare another int, call it "temp" or something. then you will want to make the temp integer as 100*age.
Then output that to the console.
should look something like this
int age = 47, temp;
temp = age * 100;
Console.WriteLine("My age is: " + temp);
It's been a while since I did anything in c# so the writeline syntax could be wrong.[/QUOTE]
Thanks! :D
Why can't I assign strings or integers to an array like this? (C#)
The error is: [I]"Use of unassigned local variable 'string1/2/3'"[/I]
Or: [I]"Use of unassigned local variable 'integer1/2/3'"[/I] if I use integers instead.
[csharp]
string string1, string2, string3;
string[] array = { string1 , string2 , string3 };
Console.Write("First string in the array = ?");
string1 = Console.ReadLine();
Console.Write("Second string in the array = ?");
string2 = Console.ReadLine();
Console.Write("Third string in the array = ?");
string3 = Console.ReadLine();
foreach (string write in array)
{
Console.WriteLine("{0}", write);
}
Console.ReadLine();
[/csharp]
[editline]a[/editline]
Nevermind got it working just by moving the line:
[csharp]
string string1, string2, string3;
Console.Write("First string in the array = ?");
string1 = Console.ReadLine();
Console.Write("Second string in the array = ?");
string2 = Console.ReadLine();
Console.Write("Third string in the array = ?");
string3 = Console.ReadLine();
string[] array = { string1 , string2 , string3 };
foreach (string write in array)
{
Console.WriteLine("{0}", write);
}
Console.ReadLine();
[/csharp]
These simple mistakes, man.
I think it's because ReadLine is not guaranteed to return a result; it could have an exception. Either handle exceptions to return a null or add your strings to a dynamic array later.
[QUOTE=ROBO_DONUT;34838016]What I want to do is stop execution, then resume at the same point in code.[/QUOTE]
The Ext.Loader component in ExtJS 4 seems to do this somehow, so it might be a good place to start looking. I don't know how it's implemented, but it if you call Ext.create() and specify a class name that hasn't been loaded yet, the loader somehow suspends execution, loads a .js file into the page (which means waiting for a callback when it's done), then resumes. Other events can be handled while the script is loading.
I saw evidence of this earlier today, actually. A coworker showed me a function that logs two debug messages with an Ext.create() call in between, and the Firebug log window had messages from [i]other[/i] event handlers between those two messages. He was asking me whether JavaScript is multithreaded, because that's what it looked like from the output.
Ext.Loader's "synchronous loading" is the thing to read about.
I'm using C++ + SDL + OpenGL, and it seems that when I call SDL_SetVideoMode, it hangs for 5-10 seconds before returning.
I think I vaguely remember this issue occurring the last time I was using SDL (a long time ago), so I had hunch that this is something someone with experience with SDL might be familiar with.
From my research, it seems this issue is caused by not cleaning up SDL properly after your last use, but as far as I can tell, I am. I don't make any surfaces other than the main one, and explicitly freeing that, as well as calling SDL_Quit() does nothing to stop this hang from occurring.
In objective-c, what's the diffirence between putting a + in front of a function and a -? I'm still not sure.
[QUOTE=_NewBee;34862257]In objective-c, what's the diffirence between putting a + in front of a function and a -? I'm still not sure.[/QUOTE]
+ denotes a static function, - denotes a non-static (member?) function.
That's how I know it anyway
Do you have an example of when I should use a + and when I should use a -?
[QUOTE=_NewBee;34862284]Do you have an example of when I should use a + and when I should use a -?[/QUOTE]
Well the difference would be this
Static method:
[UIView alloc]
Non-static Method
[variable init]
At this point you should just look up uses for static class members / functions etc.
That actually makes a lot of sense. Thanks.
I have this code:
[csharp]
public class Game
{
RenderWindow window;
int startTime;
float delta = 0.0f;
Map map;
public Game()
{
window = new RenderWindow(new VideoMode((uint)SettingsManager.Settings.WindowWidth, (uint)SettingsManager.Settings.WindowHeight, 32), "SFML.Net Window", Styles.Default, new ContextSettings(32, 0));
SettingsManager.SaveSettings();
Tile.MakeTiles();
map = new Map("b");
TextureManager.StartLoadingThread();
// Setup event handlers
window.Closed += new EventHandler(OnClosed);
window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
startTime = Environment.TickCount;
}
~Game()
{
TextureManager.Dispose();
}
public float GetDelta()
{
return delta;
}
public void Run()
{
// Start the game loop
while (window.IsOpen())
{
// Process events
window.DispatchEvents();
delta = (Environment.TickCount - startTime);
startTime = Environment.TickCount;
// Activate the window before using OpenGL commands.
// This is useless here because we have only one window which is
// always the active one, but don't forget it if you use multiple windows
window.SetActive();
// Clear screen
window.Clear(SFML.Graphics.Color.White);
map.Draw(window);
window.Draw(new SFML.Graphics.Text(GetDelta() + " ms", SFML.Graphics.Font.DefaultFont, 12));
// Finally, display the rendered frame on screen
window.Display();
}
}
/// <summary>
/// Function called when the window is closed
/// </summary>
void OnClosed(object sender, EventArgs e)
{
Window window = (Window)sender;
window.Close();
}
/// <summary>
/// Function called when a key is pressed
/// </summary>
void OnKeyPressed(object sender, KeyEventArgs e)
{
Window window = (Window)sender;
if (e.Code == Keyboard.Key.Escape)
window.Close();
}
}[/csharp]
[csharp]class Map
{
byte[,] map;
public Map(){}
public Map(string filename)
{
System.Drawing.Bitmap mapText = new System.Drawing.Bitmap("./Resources/Maps/Level1.png");
Console.WriteLine(mapText.Width + ":" + mapText.Height);
map = new byte[mapText.Width, mapText.Height];
for(int i = 0; i < map.GetLength(0);i++)
{
for(int j = 0; j < map.GetLength(1); j++)
{
Console.WriteLine(i + ":" + j);
if(mapText.GetPixel(i,j) == System.Drawing.Color.Black)
map[i,j] = 1;
else map[i,j] = 0;
}
}
}
public void Draw(SFML.Graphics.RenderWindow target)
{
Console.WriteLine("Drawng Map");
int imax = map.GetLength(0);
int jmax = map.GetLength(1);
for(int i = 0; i < imax ;i++)
{
for(int j = 0; j < jmax; j++)
{
Tile.tiles[map[i,j]].Draw(target, new SFML.Window.Vector2f(16*i, 16*j) );
Console.WriteLine(i + ":" + j);
}
}
}
}[/csharp]
[csharp]class Tile
{
public enum Tiles
{
Empty,
Solid,
Top,
Right,
Bottom,
Left,
TopLeftCorner,
TopRightCorner,
BottomRightCorner,
BottomLeftCorner,
OpenTopLeft,
OpenTopRight,
OpenBottomRight,
OpenBottomLeft,
OpenTop,
OpenRight,
OpenBottom,
OpenLeft
}
public static List<Tile> tiles;
public static void MakeTiles()
{
string TB = "./Resources/Images/TilesBlack.png";
string TW = "./Resources/Images/TilesWhite.png";
tiles = new List<Tile>();
tiles.Add(new Tile(TB, TW, null, null, 0, 16, 5));
tiles.Add(new Tile(TB, TW, null, null, 0, 16, 10));
tiles.Add(new Tile(TB, TW, null, null, 0, 16, 1));
tiles.Add(new Tile(TB, TW, null, null, 90, 16, 1));
tiles.Add(new Tile(TB, TW, null, null, 180, 16, 1));
tiles.Add(new Tile(TB, TW, null, null, 270, 16, 1));
tiles.Add(new Tile(TB, TW, null, null, 0, 16, 0));
tiles.Add(new Tile(TB, TW, null, null, 90, 16, 0));
tiles.Add(new Tile(TB, TW, null, null, 180, 16, 0));
tiles.Add(new Tile(TB, TW, null, null, 270, 16, 0));
tiles.Add(new Tile(TB, TW, null, null, 0, 16, 2));
tiles.Add(new Tile(TB, TW, null, null, 90, 16, 2));
tiles.Add(new Tile(TB, TW, null, null, 180, 16, 2));
tiles.Add(new Tile(TB, TW, null, null, 270, 16, 2));
tiles.Add(new Tile(TB, TW, null, null, 0, 16, 10));
tiles.Add(new Tile(TB, TW, null, null, 90, 16, 10));
tiles.Add(new Tile(TB, TW, null, null, 180, 16, 10));
tiles.Add(new Tile(TB, TW, null, null, 270, 16, 10));
}
Sprite sprite1;
Sprite sprite2;
RenderStates state1;
RenderStates state2;
public Tile(string imageLayer1, string imageLayer2, Shader shade1, Shader shade2 ,float rotation, int tileSize, int tileIndex)
{
state1 = new RenderStates(BlendMode.Alpha);
state2 = new RenderStates(BlendMode.Alpha);
if(shade1 != null) state1.Shader = shade1;
if(shade2 != null) state2.Shader = shade2;
sprite1 = new Sprite();
sprite1.Texture = TextureManager.GetFile(imageLayer1);
int x = (int)((tileIndex * tileSize * 4) / sprite1.Texture.Width);
int y = (int)((tileIndex * tileSize * 4) % sprite1.Texture.Height);
sprite1.TextureRect = new IntRect(x, y, tileSize*4, tileSize*4);
sprite1.Scale = new SFML.Window.Vector2f(0.25f, 0.25f);
sprite1.Origin = new SFML.Window.Vector2f(tileSize/2,tileSize/2);
sprite1.Rotation = rotation;
sprite2 = new Sprite();
sprite2.Texture = TextureManager.GetFile(imageLayer2);
sprite2.TextureRect = new IntRect(x, y, tileSize * 4, tileSize * 4);
sprite1.Scale = new SFML.Window.Vector2f(0.25f, 0.25f);
sprite2.Origin = new SFML.Window.Vector2f(tileSize / 2, tileSize / 2);
sprite1.Rotation = rotation;
}
public void Draw(SFML.Graphics.RenderWindow target, SFML.Window.Vector2f position)
{
sprite1.Position = position;
sprite2.Position = position;
target.Draw(this.sprite1, this.state1);
target.Draw(this.sprite2, this.state2);
}
}[/csharp]
Runng with mono but it takes like 2 or 3 seconds each frame, I have tried a couple of optimizations but cant get it any lower than that.
Is there anything else I could do?
Also do you think I would notice any big performance upgrades if I were to be using C++ instead?
[editline]25th February 2012[/editline]
Damn, on windows it runs at around 60fps.
Looks like C++ it is :/
snip
[QUOTE=Richy19;34862372]I have this code:
Runng with mono but it takes like 2 or 3 seconds each frame, I have tried a couple of optimizations but cant get it any lower than that.
Is there anything else I could do?
Also do you think I would notice any big performance upgrades if I were to be using C++ instead?
[editline]25th February 2012[/editline]
Damn, on windows it runs at around 60fps.
Looks like C++ it is :/[/QUOTE]
Have you tried profiling it? You might be able to pinpoint where it's spending its time and submit a bug report to mono or something.
-snmpo-
Ok, I need help.
I can't get rid of this error message
1>c:\users\home\desktop\treeox\treeox\introstate.cpp(13) : error C2228: left of '.LoadFromFile' must have class/struct/union
Right now I don't really care how it gets fixed, but I would like to know whats wrong with it.
Oh and what the hell does line 6 do(in the cpp)?
IntroState.cpp
[CODE]#include "StateManager.h"
#include "GameState.h"
#include "IntroState.h"
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
IntroState IntroState::m_IntroState;
void Init()
{
//Load Splash Screen
//Draw Splash Screen
IntroState::splashScreen.LoadFromFile("splash.png");
}
void Cleanup()
{
//Clear Splash screen
}
void Pause()
{}
void Resume()
{}
void handleEvents(StateManager *manager)
{}
void Update(StateManager *manager)
{
IntroState::time = IntroState::clock.GetElapsedTime();
sf::Time time2 = Seconds(1.0f);
//if(time.AsSeconds()>=time2.AsSeconds())
//{
// manager->changeState(MainMenuState);
//}
}
void Draw(StateManager *manager)
{
sf::Sprite sprite;
sprite.SetTexture(splashScreen);
manager->mainWindow.draw(sprite);
manager->mainWindow.Display();
//Draw Splash Screen
}[/CODE]
IntroState.h
[CODE]#ifndef INTROSTATE_H
#define INTROSTATE_H
//#include <SFML/System.hpp>
#include "GameState.h"
class IntroState : public GameState
{
public:
void Init();
void Cleanup();
void Pause();
void Resume();
void handleEvents(StateManager *manager);
void Update(StateManager *manager);
void Draw(StateManager *manager);
static IntroState *Instance()
{return &m_IntroState;}
protected:
IntroState(){}
private:
static IntroState m_IntroState;
sf::Clock clock;
sf::Time time;
sf::Texture splashScreen;
};
#endif[/CODE]
I know thats not the only problem but its the one that is the focus of my attention.
[QUOTE=Richy19;34862372]I have this code:
-snip-
Runng with mono but it takes like 2 or 3 seconds each frame, I have tried a couple of optimizations but cant get it any lower than that.
Is there anything else I could do?
Also do you think I would notice any big performance upgrades if I were to be using C++ instead?
[editline]25th February 2012[/editline]
Damn, on windows it runs at around 60fps.
Looks like C++ it is :/[/QUOTE]
Is that terrible performance under Mono for Windows, OSX, or Linux? If it's under Linux than the most likely answer is that whatever video driver is being used is utter shit for graphics rendering, and the language used wouldn't matter. The other possible problem, as someone else brought up, is that Mono might have a bug that causes it to lose performance compared to MS .NET runtimes.
[editline]25th February 2012[/editline]
[QUOTE=redsoxrock;34863906]Ok, I need help.
I can't get rid of this error message
1>c:\users\home\desktop\treeox\treeox\introstate.cpp(13) : error C2228: left of '.LoadFromFile' must have class/struct/union
Right now I don't really care how it gets fixed, but I would like to know whats wrong with it.
Oh and what the hell does line 6 do(in the cpp)?
IntroState.cpp
[CODE]#include "StateManager.h"
#include "GameState.h"
#include "IntroState.h"
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
IntroState IntroState::m_IntroState;
void Init()
{
//Load Splash Screen
//Draw Splash Screen
IntroState::splashScreen.LoadFromFile("splash.png");
}
void Cleanup()
{
//Clear Splash screen
}
void Pause()
{}
void Resume()
{}
void handleEvents(StateManager *manager)
{}
void Update(StateManager *manager)
{
IntroState::time = IntroState::clock.GetElapsedTime();
sf::Time time2 = Seconds(1.0f);
//if(time.AsSeconds()>=time2.AsSeconds())
//{
// manager->changeState(MainMenuState);
//}
}
void Draw(StateManager *manager)
{
sf::Sprite sprite;
sprite.SetTexture(splashScreen);
manager->mainWindow.draw(sprite);
manager->mainWindow.Display();
//Draw Splash Screen
}[/CODE]
IntroState.h
[CODE]#ifndef INTROSTATE_H
#define INTROSTATE_H
//#include <SFML/System.hpp>
#include "GameState.h"
class IntroState : public GameState
{
public:
void Init();
void Cleanup();
void Pause();
void Resume();
void handleEvents(StateManager *manager);
void Update(StateManager *manager);
void Draw(StateManager *manager);
static IntroState *Instance()
{return &m_IntroState;}
protected:
IntroState(){}
private:
static IntroState m_IntroState;
sf::Clock clock;
sf::Time time;
sf::Texture splashScreen;
};
#endif[/CODE]
I know thats not the only problem but its the one that is the focus of my attention.[/QUOTE]
When defining class member implementations in C++ the format is
[cpp]
void ClassName::MethodName() {
//stuff
}
[/cpp]
So when you declared Init() without declaring it as IntroState::Init() it was defining a normal void function that has no knowledge of a member called 'splashScreen'.
Thanks. Fucking idiot I am. I don't know how many time I looked at the code I'm basing it off of and didn't see that.
[QUOTE=redsoxrock;34863906]Ok, I need help.
I can't get rid of this error message
1>c:\users\home\desktop\treeox\treeox\introstate.cpp(13) : error C2228: left of '.LoadFromFile' must have class/struct/union[/QUOTE]
You're trying to call a method on something that isn't an object. Is there an earlier error message regarding that splashScreen variable, maybe something about it being inaccessible? "IntroState::splashScreen" does refer to an object, but it's an object that your Init function currently doesn't have access to (because it's private) so the compiler may think you're referring to some other (undeclared) variable named "splashScreen" instead.
You need to define the functions in your .cpp file as "void IntroState::Init()", "void IntroState::Cleanup()", and so on. The way they're defined now (without the "IntroState:""), they're not definitions of the IntroState class's member functions, they're just ordinary standalone functions with no relationship to the IntroState class. That's why they don't have access to private things in IntroState (like the splashScreen).
[QUOTE=redsoxrock;34863906]Oh and what the hell does line 6 do(in the cpp)?[/QUOTE]
That defines the IntroState class's static m_IntroState variable. The line in the class definition ("static IntroState m_IntroState;") just declares it — it promises to the compiler that one of your .obj files will contain a definition of this variable when the program is linked, so it's OK for things to refer to it. The definition in the .cpp file actually puts the variable into that .obj file. It's analogous to writing the definition of a function, which puts the code for that function into the .obj file.
what's the irc channel for yall?
[QUOTE=-Kesil-;34868131]what's the irc channel for yall?[/QUOTE]
IRC channel is basically dead.
[url]http://steamcommunity.com/groups/FP_Programmers[/url]
this group's chat is pretty well used, though. 21 in chat atm.
[B]where do i put the glut files? so that i can access them for my project?[/B]
[IMG]http://i.imgur.com/spcpQ.png[/IMG]
[editline]25th February 2012[/editline]
...
...
...
...
...
Does openGL render voxel stuff? (minecraft, cubeworld)
or Do I not even begin to know what I'm talking about?
put the lib in the 2nd opengllession1 folder itself
make sure you link it too
also put glut.h in the same folder as well, then add it to your project in visual studio, if that's what you're using
[QUOTE=-Kesil-;34868351][B]where do i put the glut files? so that i can access them for my project?[/B]
[IMG]http://i.imgur.com/spcpQ.png[/IMG]
[editline]25th February 2012[/editline]
...
...
...
...
...
Does openGL render voxel stuff? (minecraft, cubeworld)
or Do I not even begin to know what I'm talking about?[/QUOTE]
It renders what you tell it to render. It does not contain a system for rendering a world made out of boxes, you have to develop that yourself.
[QUOTE=-Kesil-;34868351]Does openGL render voxel stuff? (minecraft, cubeworld)[/QUOTE]
OpenGL renders points, lines, and triangles. The terrain in Minecraft is represented as voxels in the main program that runs on the GPU, but the geometry that's fed to OpenGL is a bunch of squares (pairs of triangles) generated from the voxel data.
I always wondered if you could implement a voxelworld as a bunch of vertices (or meshes?) and a shader that renders a cube at each vertex
[editline]26th February 2012[/editline]
Points*
[QUOTE=Shoar;34868456]put the lib in the 2nd opengllession1 folder itself
make sure you link it too[/QUOTE]
[B]
done?[/B]
[IMG]http://i.imgur.com/wdJX5.png[/IMG]
[B]
so to link to it... I did this ...[I][U]. right?[/U][/I]
[/B][IMG]http://i.imgur.com/xMbMN.png[/IMG]
I'm pretty new to syntax of C++ and Visual Studio.
Don't worry though. all I need to do is draw lines and boxes or circles... I'm not asking to create some mega 3D engine
Sorry, you need to Log In to post a reply to this thread.