You would have to do ( a == x || a == y || a == z ). It doesn't flag as invalid syntax but, for example,
[cpp]int a = 1;
if ( a == 2, 3, 4 )
std::cout << "true";[/cpp]
Would print true.
[QUOTE=Elffie;30157963]You would have to do ( a == x || a == y || a == z ). It doesn't flag as invalid syntax but, for example,
[cpp]int a = 1;
if ( a == 2, 3, 4 )
std::cout << "true";[/cpp]
Would print true.[/QUOTE]
Wait, why? I thought the statements get evaluated from left-to-right and then the [B]leftmost[/B] is returned?
I would tell you but I have absolutely no idea, it just does; at least on Visual Studio 2010. I'm going to try this on CodeBlocks just in case its compiler related.
I just remembered wrong, it seems.
[QUOTE=adam78;30148992]could someoe help me im geting dossed alot how can i stop this from happening ty[/QUOTE]
Stop using internet explorer
Well it prints true on CodeBlocks as well, I thought x, y, z would flag as invalid syntax.
[QUOTE=Elffie;30159319]Well it prints true on CodeBlocks as well, I thought x, y, z would flag as invalid syntax.[/QUOTE]
But
x, y, z is completely valid. It's the comma operator.
And as said, I remembered wrong, that's how it should work.
Can anyone point me to any good tutorials or books on using/setting up XNA 4 for 3D?
[QUOTE=esalaka;30159419]But
x, y, z is completely valid. It's the comma operator.
And as said, I remembered wrong, that's how it should work.[/QUOTE]
Oh yeah, of course! So this:
[cpp]if ( true, false )
std::cout << "true" << std::endl;[/cpp]
Doesn't print, as false is well false. Heh, well that may come in handy time, thanks.
Ok, So I am learning assembly but I want to make windows executables. What assembler is best for this job?
NASM is good or so I hear
[QUOTE=benjojo;30160143]Ok, So I am learning assembly but I want to make windows executables. What assembler is best for this job?[/QUOTE]
I think NASM is the most popular.
Any assembler for Windows can produce Windows-executable binaries AFAIK, they just need a PE switch or something
[editline]31st May 2011[/editline]
Overv don't break my automerge by saying the same thing :saddowns:
[QUOTE=esalaka;30160165]Any assembler for Windows can produce Windows-executable binaries AFAIK, they just need a PE switch or something
[editline]31st May 2011[/editline]
Overv don't break my automerge by saying the same thing :saddowns:[/QUOTE]
Says the guy who ninja'd me :(
Well I had issues with NASM with getting it to compile a 32bit executable.
[img]http://img38.imageshack.us/img38/2901/screenshot2011053118342.png[/img]
[code]
section .text
global _WinMain@16
_WinMain@16:
mov eax, 0
ret 16
[/code]
Do forgive me if I am doing something stupid here, I have not really dabbled with windows and NASM
[QUOTE=benjojo;30160232]Well I had issues with NASM with getting it to compile a 32bit executable.
[img]http://img38.imageshack.us/img38/2901/screenshot2011053118342.png[/img]
[code]
section .text
global _WinMain@16
_WinMain@16:
mov eax, 0
ret 16
[/code]
Do forgive me if I am doing something stupid here, I have not really dabbled with windows and NASM[/QUOTE]
[url=http://www.nasm.us/xdoc/2.09.08/html/nasmdoc2.html#section-2.1.2]This might help[/url]
[editline]31st May 2011[/editline]
I mean the part about listing output types.
Windows binary is probably PE32 and not Win32
[QUOTE=esalaka;30160382][url=http://www.nasm.us/xdoc/2.09.08/html/nasmdoc2.html#section-2.1.2]This might help[/url]
[editline]31st May 2011[/editline]
I mean the part about listing output types.
Windows binary is probably PE32 and not Win32[/QUOTE]
Ok, Well doing the same thing but switching 32 for 64 works, So I'm guessing I would have to assemble my program on a 32bit system to have a 32bit exe?
[editline]31st May 2011[/editline]
Correction, No that was dumb, Tried it in Xp mode and still produced a 16bit exe :sigh:
Funny, it works for me on Linux.
[code][esa@esa-pc-arch b](master)$ nasm -f win32 -o test.obj msa.asm
[esa@esa-pc-arch b](master)$ i486-mingw32-ld -o test.exe test.obj
[esa@esa-pc-arch b](master)$ file msa.asm test.obj test.exe
msa.asm: ASCII text
test.obj: 80386 COFF executable not stripped - version 30821
test.exe: PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows[/code]
[editline]31st May 2011[/editline]
Ignore the git stuff, I have my random source code in a directory that's under version control for some reason.
[editline]31st May 2011[/editline]
Oh
[code][esa@esa-pc-arch ~]$ cat src/b/msa.asm
nop ;FUK YEAH BIPCHES[/code]
Ok, I might just give up with this overall, Its looking like its not going to work for me and im getting more and more pissed off by the second.
[editline]31st May 2011[/editline]
Assembly really does a good job of making me feel stupid and get annoyed.
[editline]31st May 2011[/editline]
[code]
C:\Program Files (x86)\NASM>nasm -f win64 herp.asm -o test.o
C:\Program Files (x86)\NASM>ld test.o -o test.exe
C:\Program Files (x86)\NASM>test
C:\Program Files (x86)\NASM>
[/code]
Is the only thing that will work, one that is a 64 bit file so it is not usable for me because my stuff has to run on 32bit systems too.
I'm trying to find out what vertices are at my cursor from a terrain map in 3d space.
I can Unproject to get the 2d screen cords sort of in 3d, but I have a hard time getting the actual position because it can't collide with my terrain. Any thoughts?
[QUOTE=benjojo;30160953]Ok, I might just give up with this overall, Its looking like its not going to work for me and im getting more and more pissed off by the second.
[editline]31st May 2011[/editline]
Assembly really does a good job of making me feel stupid and get annoyed.
[editline]31st May 2011[/editline]
[code]
C:\Program Files (x86)\NASM>nasm -f win64 herp.asm -o test.o
C:\Program Files (x86)\NASM>ld test.o -o test.exe
C:\Program Files (x86)\NASM>test
C:\Program Files (x86)\NASM>
[/code]
Is the only thing that will work, one that is a 64 bit file so it is not usable for me because my stuff has to run on 32bit systems too.[/QUOTE]
Try ld -mi486-mingw32 test.o -o test.exe for the 32-bit object file.
In notepad++, is there a way to change the colours of the toolbars etc. as well as the editing pane? I've set it to use the dark theme but it looks odd with bright toolbars.
[QUOTE=benjojo;30160232]Well I had issues with NASM with getting it to compile a 32bit executable.
[img]http://img38.imageshack.us/img38/2901/screenshot2011053118342.png[/img][/QUOTE]
NASM produced a 32-bit object file just like you asked it to, but you're trying to link it into a 64-bit executable. You need to tell the linker to produce 32-bit output too.
In pygame, if I create a bunch of instances of the same class with a loop and stick them in a RenderPlain group, how would I remove a specific instance from that group? I'm making a simple game in which a bunch of these instances are scattered about and when the player touches one it gets "eaten".
Can anyone suggest a good way to do SFML collision between sprites in C++? As in, something along the lines of:
if(spritestouch() = true)
{
code
}
Alright. Got a problem with a simple text-based game I'm working with in Java. Here's some of the overhead code:
[code]public class Game
{
//player info arrays
String[] name = new String[2];
int[] health = new int[2];
int[] style = new int[2];
int[] weapon = new int[2];
Random rand = new Random();
Scanner in = new Scanner(System.in);
public Game()
{
getInfo();
gameLoop();
}
public void getInfo()
{
name[0] = getName();
style[0] = getStyle();
weapon[0] = getWeapon();
health[0] = getHealth();
System.out.println();
name[1] = getName();
style[1] = getStyle();
weapon[1] = getWeapon();
health[1] = getHealth();
System.out.println("\nThis battle is between " + name[0] + " and " + name[1]);
System.out.println(name[0] + "'s health is: " + health[0]);
System.out.println(name[1] + "'s health is: " + health[1]);
}
public String getName()
{
System.out.println("BEGIN NAME");
System.out.print("Enter your character's name: ");
String pname = in.nextLine();
System.out.println("RETURN NAME");
return pname;
}
public int getStyle()
{
System.out.println("BEGIN STYLE");
System.out.print("Choose your playstyle: Attack<1>, Defense<2>, or Lucky<3>: ");
int pstyle = in.nextInt();
System.out.println("RETURN STYLE");
return pstyle;
}
public int getWeapon()
{
System.out.println("BEGIN WEAPON");
System.out.print("Choose your weapon: Sword<1>, Axe<2>, or Flail<3>: ");
int pweapon = in.nextInt();
System.out.println("RETURN WEAPON");
return pweapon;
}
public int getHealth()
{
int phealth = rand.nextInt(101) + 900; //900 - 1000
return phealth;
}[/code]
Yes, there's a lot of test lines in there. The problem I'm having is if I comment out all the lines in getInfo except the two getName calls, those two methods function as normal. If, however, I uncomment any of the lines asking for weapons or styles, then the second name is [i]never saved![/i] It skips that step, prints "RETURN NAME" and never asks for any input, continuing on to weapon, etc. input (which functions as normal).
Any help? This should all compile straight into a blank Java file, if you throw this in:
[code]public static void main(String[] args)
{
Game g = new Game();
}[/code]
[QUOTE=amazer97;30170356]Can anyone suggest a good way to do SFML collision between sprites in C++? As in, something along the lines of:
if(spritestouch() = true)
{
code
}[/QUOTE]
For starters that should be spritestouch() [B]==[/B] true :P
As for collision detection, how precise do you need it? If your sprites are generally circular, or rectangular, or any other primitive shape, you can use some very simple collision checks. If you need pixel precision, you can do that as well but it IS slower.
So, what do you need. Precise and slow? Or vague and fast.
I'm making a day/night system, by changing the background color, using timers. Now, I have one problem, the color doesn't seem to be updating correctly.
I draw the background by just doing a fillRect(), like this:
[cpp] public void drawBuffer(){
Graphics2D g = buffer.createGraphics();
g.setColor(new Color(r1,g1,b1));
g.fillRect(0,0,800,600);
}[/cpp]
It draws the background, with the starting colors, 135,206,250, but, It should immediatly start to turn darker, because of my Timer. I did my timer like this: [cpp] Timer timer = new Timer(100, new SkyColor());
class SkyColor implements ActionListener{
public void actionPerformed(ActionEvent e){
if(r1 >= 0){
r1--;
}else{
timer.stop();
}
}
}[/cpp]
And I started the timer in my initialize method, which runs at the start of my game. So it should basically turn my red value down every 1/10'th of a second. But the problem is, it isn't turning darker. and I think it's because it creates just one color, then doesn't look at it again, so it won't like, update the r1 in the color. Any help with how to fix this?
How would I move an item along a vector. I have a starting vector and a destination vector. I know how to move it in the direction, but I'm not sure how to move it directly onto the other vector, or to check when it's close (to check for overlap).
Does anyone know how to programatically force the android keyboard into full screen IME mode?
I can't get the bloody thing to work properly.
Sorry, you need to Log In to post a reply to this thread.