[QUOTE=theJohn;33215523]How would I go about to create simple animations in a platform game with LÖVE? I can't come up with an efficient way to do it since I'm pretty new to game development. Perhaps it is over my skill level but it just looks so boring when the character floats along the ground.[/QUOTE]
Instead of a single sprite, have multiple sprites representing the frames of your animation and then simply draw them one after another in your game. The more time you wait before switching image, the slower the animation will be. Simple, really!
Is the volatile keyword necessary in C++ for multithreading? I use it all the time in C# for multithreading and just realized C++ has it too... never had any issues without it though.
I'm getting this error when trying to make a struct (that contains an std::string) volatile and assigning to that string:
[quote]error C2678: binary '=' : no operator found which takes a left-hand operand of type 'volatile std::string' (or there is no acceptable conversion)[/quote]
[cpp]gServerInfo.name = "My Server";[/cpp]
Even if volatile is necessary in C++, the separate thread that I have simply reads from the structure and never actually writes anything. Am I correct in assuming that I do not need to use volatile because of this?
So I have this:
[cpp]
enum Resolutions
{...}
[/cpp]
[cpp]Resolutions OptionsSettingsValue::Resolution;[/cpp]
[cpp]
switch(OptionsSettingsValue::Resolution)
{...}
[/cpp]
but I get:
[quote]error C2450: switch expression of type 'std::string' is illegal[/quote]
fixed
I'm doing a question that involves comparing brackets and if they close then it returns true else returns false. For example, a(bc)d(ef) is correctly bracketed, but a[bc)) is not correctly bracketed.
It keeps returning false for me and I can't see why
[code]class Q2 {
static boolean isString(String exp){
Stack<Character> brack = new Stack<Character>();
for(int i = 0; i < exp.length(); i ++){
if(exp.charAt(i)=='[' || exp.charAt(i)=='{'||exp.charAt(i)=='(')
brack.push(exp.charAt(i));
}
for(int k = exp.length()-1; k >= 0; k--){
if(exp.charAt(k)==']' || exp.charAt(k)=='}'||exp.charAt(k)==')'){
if(brack.pop() != exp.charAt(k)){
return false;
}
}
}
return true;
}
public static void main(String[] args) {
String s = "a[bc]aj(ip)";
String k0 = "a(b{cd})e[]fg";
String i = "a(bc)[d}e";
if(isString(s)== true)
System.out.println("true");
else System.out.println("false");
}
}
[/code]
At first glance I'm noticing that
[cpp]
if(exp.charAt(k)==']' || exp.charAt(k)=='}'||exp.charAt(k)==')'){
if(brack.pop() != exp.charAt(k)){
return false;
}
}
[/cpp]
Should always return false because the only characters being pushed are '(','{',and '[' and when you pop those you're comparing them to ')','}', and ']'
Has anybody here got a clue about c#?
I'm having this problem right now:
[img]http://team-s4s.de/screenshots/Screenshot-2011-11-10_22.34.32.png[/img]
I can't really brain today and it's kind of annoying me. I am trying to extract something out of this string
"blabla COLOR >31,15,12" (for example)" so I need the stuff between > and , but it kind of fails me atm.
[QUOTE=Dominik93;33221078]Has anybody here got a clue about c#?
I'm having this problem right now:
[img]http://team-s4s.de/screenshots/Screenshot-2011-11-10_22.34.32.png[/img]
I can't really brain today and it's kind of annoying me. I am trying to extract something out of this string
"blabla COLOR >31,15,12" (for example)" so I need the stuff between > and , but it kind of fails me atm.[/QUOTE]
[url]http://msdn.microsoft.com/en-us/library/aa904308%28v=VS.71%29.aspx[/url]
[i]startIndex plus length indicates a position not within this instance.
-or-
startIndex or length is less than zero.[/i]
You're calling Substring(index0, index1) when you should call it like Substring(index0, index1 - index0 + 1). The second argument is supposed to be the length of the substring, not the index of the last character.
[QUOTE=ThePuska;33221293][url]http://msdn.microsoft.com/en-us/library/aa904308%28v=VS.71%29.aspx[/url]
[i]startIndex plus length indicates a position not within this instance.
-or-
startIndex or length is less than zero.[/i]
You're calling Substring(index0, index1) when you should call it like Substring(index0, index1 - index0 + 1). The second argument is supposed to be the length of the substring, not the index of the last character.[/QUOTE]
Thanks but I tried these things and I still can't get it to work.
My code right now is
[code] redstring = e.Message.Substring(e.Message.IndexOf(">" + 1), ( e.Message.IndexOf(",") - e.Message.IndexOf(">" + 1)));[/code] which is probably still wrong ...
edit:
okay done it like this:
[code] int start = e.Message.IndexOf(">");
int end = e.Message.IndexOf(",");
redstring = e.Message.Substring(start, end - start - 1);[/code]
right now and it works, thanks.
[QUOTE=jalb;33217354]Is the volatile keyword necessary in C++ for multithreading? I use it all the time in C# for multithreading and just realized C++ has it too... never had any issues without it though.
I'm getting this error when trying to make a struct (that contains an std::string) volatile and assigning to that string:
[cpp]gServerInfo.name = "My Server";[/cpp]
Even if volatile is necessary in C++, the separate thread that I have simply reads from the structure and never actually writes anything. Am I correct in assuming that I do not need to use volatile because of this?[/QUOTE]Here's the MSDN article about the keyword, it should explain it to you
[url]http://msdn.microsoft.com/en-us/library/12a04hfd.aspx[/url]
[QUOTE=danharibo;33222193]Here's the MSDN article about the keyword, it should explain it to you
[url]http://msdn.microsoft.com/en-us/library/12a04hfd.aspx[/url][/QUOTE]
No where do they mention strings. Nor do they reassure what I've asked.
I appreciate the help but MSDN was my first stop. After much googling it also seems that volatile with std::string is a bit of a mystery. I think I'm fine without volatile but I was hoping for some reassurance here because I don't completely understand the nature of multithreading.
[QUOTE=jalb;33222273]No where do they mention strings. Nor do they reassure what I've asked.
I appreciate the help but MSDN was my first stop. After much googling it also seems that volatile with std::string is a bit of a mystery. I think I'm fine without volatile but I was hoping for some reassurance here because I don't completely understand the nature of multithreading.[/QUOTE][quote=The First Paragraph]The volatile keyword is a type qualifier used to declare that an object can be modified in the program by something such as the operating system, the hardware, or a [i]concurrently executing thread.[/i][/quote]
I know what volatile is for.
I'm wondering why it doesn't let me use volatile strings and if it's even necessary in C++ when I'm not doing writing operations.
[QUOTE=Richy19;33220388]So I have this:
[cpp]
enum Resolutions
{...}
[/cpp]
[cpp]Resolutions OptionsSettingsValue::Resolution;[/cpp]
[cpp]
switch(OptionsSettingsValue::Resolution)
{...}
[/cpp]
but I get:
fixed[/QUOTE]
How?
[QUOTE=Dominik93;33221417]Thanks but I tried these things and I still can't get it to work.
My code right now is
[code] redstring = e.Message.Substring(e.Message.IndexOf(">" + 1), ( e.Message.IndexOf(",") - e.Message.IndexOf(">" + 1)));[/code] which is probably still wrong ...
edit:
okay done it like this:
[code] int start = e.Message.IndexOf(">");
int end = e.Message.IndexOf(",");
redstring = e.Message.Substring(start, end - start - 1);[/code]
right now and it works, thanks.[/QUOTE]
Your original code was doing
[csharp] int start = e.Message.IndexOf(">1");
int end = e.Message.IndexOf(",");
redstring = e.Message.Substring(start, end - start - 1);[/csharp]
and IndexOf returns -1 if the string is not found.
[QUOTE=Map in a box;33223861]How?[/QUOTE]
I hadnt included the OptionsSettings Header
Is using QT a bad idea?
No.
Java -Trying to load a simple text file of integers into the applet and display it on the map(which is a gridmap).
The tile data is a 2d int array
[code]
//other bits incase its needed for help purposes
public int[][] tile_data = new int[applet_width][applet_height];
//block datas
public int BLOCK_AIR = 0;
public int BLOCK_BLOCKED = 1;
//load map function
public void loadMap()
{
try
{
sc = new Scanner(new File(testFile));
while(sc.hasNextLine())
{
String s = sc.nextLine();
System.out.println(s);
int i = Integer.parseInt(s);
for(int x=1; x < 10; x++) // should be more than that, but its only for testing, just trying to get it to work, all has failed
{
for(int y=0; y< 10; y++)
{
tile_data[x][y] = i;
}
}
}
}
catch(IOException ex) {}
}
[/code]
[code]
100000000
101111010
010001010
011111110
011001000
011000000
011000000
011111110
011111110
000000000
[/code]
I know some of that code is not needed, but I'm just trying alot of stuff here, nothing seems to work that I've tried
[img]http://dl.dropbox.com/u/1379367/applet_1.JPG[/img]
that blue square was the player, but its removed until I get the map loading working.
Sorry if I'm not clear, just a bit tired.
Any help on this? I've tried alot, cant seem to get it to work.
[code]
String s = sc.nextLine();
System.out.println(s);
int i = Integer.parseInt(s);
[/code]
Unless you have 1 digit per line that's going to parse the whole line to an int
In the example map you gave, that would set every single tile to 0 because the last line it reads is 0000000000 and it sets every tile in the 10x10 grid to that number.
2 things you need to fix-
1) Parse numbers per-character instead of per-line
2) Set the tiledata based on the position of the character rather than setting every single tile to the number you just parsed
EDIT:
Pseudocode:
[code]
let y = 0
while the scanner has a line to read
let line = read a line from the scanner
for x = 0, x is less than the length of the line, increment x
let i = parse the character at line[x] to an integer
set the tiledata at coordinates (x, y) to i
increment y
[/code]
This is less programming help and more editor help. Does anyone know how to make sublime text 2 send a file to lua? I'm having problems with the custom build system.
Anyone familiar with the lidgren networking library?
I'm trying to use:
NetIncomingMessage.WriteAllProperties(myObj)
NetIncomingMessage.ReadAllProperties(myObj)
However, once I write the properties and read it on the client, all my values are null. I can send data just fine via the normal NetIncomingMessage.Write(data) method, however I'd much rather use WriteAllProperties.
Anyone know what might be up?
[editline]13th November 2011[/editline]
Nevermind, was able to fix it (Had to make my properties available with getters/setters). I feel dumb :v:
Does anyone know how I can use LuaZip with my Love game?
[code] static int[] getpx(double lat, double longa, int height, int width)
{
int[] res = new int[2]; // What the ratio should be: 2:1, What we need it to be 16:10
res[0] = (int)(((longa + 180) * (width / (360))));
res[1] = (int)(((lat * -1) + 90) * (height / (180)) );
return res;
}[/code]
So this works fine for 2:1 images but when I give it a 16:10 image it begins to go nuts, I cant really figure out how to fix that, I'm sure its something simple.
[cpp]Algorithm insertionsort(A, n):
Input: An array A storing n integers.
Output: An array with the same integers in ascending order.
for i = 1 to n-1
Move A[i] to its correct position
within the subarray A[0..i][/cpp]
Sigh, is this really the psuedocode for insertion sort?
[editline]13th November 2011[/editline]
It looks like it lacks a lot. Other descriptions of insertion sort is completely different from that one.
[editline]13th November 2011[/editline]
I'm just wondering if you as an experienced programmer would recognize that this is "insertion sort", just by looking at the code.
[QUOTE=Swebonny;33258900][cpp]Algorithm insertionsort(A, n):
Input: An array A storing n integers.
Output: An array with the same integers in ascending order.
for i = 1 to n-1
Move A[i] to its correct position
within the subarray A[0..i][/cpp]
Sigh, is this really the psuedocode for insertion sort?
[editline]13th November 2011[/editline]
It looks like it lacks a lot. Other descriptions of insertion sort is completely different from that one.
[editline]13th November 2011[/editline]
I'm just wondering if you as an experienced programmer would recognize that this is "insertion sort", just by looking at the code.[/QUOTE]
Yes, that's insertion sort.
[editline]13th November 2011[/editline]
It progresses through the array one entry at a time, ensuring that the part of the array that precedes the current index is sorted.
[img]http://upload.wikimedia.org/wikipedia/commons/2/25/Insertion_sort_animation.gif[/img]
[QUOTE=ThePuska;33259447]Yes, that's insertion sort.[/QUOTE]
What parts gives it away?
Is it the move "to its correct position within the subarray A[0..i]"?
[QUOTE=Swebonny;33258900]
Algorithm insertionsort(A, n): Input: An array A storing n integers. Output: An array with the same integers in ascending order. for i = 1 to n-1 Move A[i] to its correct position within the subarray A[0..i]
Sigh, is this really the psuedocode for insertion sort?
[editline]13th November 2011[/editline]
It looks like it lacks a lot. Other descriptions of insertion sort is completely different from that one.
[editline]13th November 2011[/editline]
I'm just wondering if you as an experienced programmer would recognize that this is "insertion sort", just by looking at the code.[/QUOTE]
That's like [I]pseudo[/I]-pseudo-code. But it does describe a generic insertion sort.
Might as well have been:
[cpp]Algorithm insertionsort(A, n):
Input: An array A storing n integers.
Output: An array with the same integers in ascending order.
for i = 1 to n-1
Move things around in an insertion-sort-like manner
until sorted[/cpp]
[QUOTE=Anonim;33259492]That's like [I]pseudo[/I]-pseudo-code. But it does describe a generic insertion sort.
Might as well have been:
Algorithm insertionsort(A, n): Input: An array A storing n integers. Output: An array with the same integers in ascending order. for i = 1 to n-1 Move things around in an insertion-sort-like manner until sorted[/QUOTE]
Thanks, now I know I'm not retarded :v: Because it seriously confused me.
-oh my snipping snip-
Apparently IDLE is packaged with the installer of 3.22 for Python. It'd help if I would've ran it to begin with, heh.
In Lua, I'm trying to do something along the lines of the following:
[code]
tableA = { blah, blah2, blah3 }
tableB = tableA
[/code]
However, when I do this, if I change tableA tableB also updates, even when I'm not asking it to. I'm guessing it's only referencing tableA, but not copying it. How do I go about actually copying it, so I can change tableA without tableB also updating?
Is the best way to iterate over all the values and copy them over?
Sorry, you need to Log In to post a reply to this thread.