Can someone help me?
I'm going through a DirectX book, this is the "on your own" part of the Drawing and Animating Sprites chapter.
Here is my code.
Sprite Draw and Animate Functions:
[cpp]
void Sprite_Draw_Frame(LPDIRECT3DTEXTURE9 texture, int destx, int desty, int framenum, int framew, int frameh, int columns)
{
D3DXVECTOR3 position((float)destx, (float)desty, 0);
D3DCOLOR white = D3DCOLOR_XRGB(255, 255, 255);
RECT rect;
rect.left = (framenum % columns) * framew;
rect.top = (framenum / columns) * frameh;
rect.right = rect.left + framew;
rect.bottom = rect.top + frameh;
spriteobj->Draw(texture, &rect, NULL, &position, white);
}
void Sprite_Animate(int &frame, int startframe, int endframe, int direction, int &starttime, int delay)
{
if((int)GetTickCount() > starttime + delay)
{
starttime = GetTickCount();
frame += direction;
if(frame > endframe) frame = startframe;
if(frame < startframe) frame = endframe;
}
}
[/cpp]
Rendering function:
[cpp] if (d3ddev->BeginScene())
{
spriteobj->Begin(D3DXSPRITE_ALPHABLEND);
Sprite_Animate(frame, 0, 29, 1, starttime, 1);
Sprite_Draw_Frame(explosion, 200, 200, frame, 128, 128, 6);
//stop rendering
spriteobj->End();
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}
if (d3ddev->BeginScene())
{
spriteobj->Begin(D3DXSPRITE_ALPHABLEND);
int i = 0;
while(i < 200)
{
Sprite_Animate(frame, 0, 29, 1, starttime, 1);
Sprite_Draw_Frame(explosion, 200 + i, 200 + i, frame, 128, 128, 6);
i += 100;
}
//stop rendering
spriteobj->End();
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}[/cpp]
1. The Animate Sprite project in this chapter does show how animation works, but it's kind of a boring demo. Modify the program so that it generates more than one explosion sprite at a time.
I did do that, but not the way it intended. I just did this:
[cpp] if (d3ddev->BeginScene())
{
spriteobj->Begin(D3DXSPRITE_ALPHABLEND);
int i = 0;
while(i < 200)
{
Sprite_Animate(frame, 0, 29, 1, starttime, 1);
Sprite_Draw_Frame(explosion, 200 + i, 200 + i, frame, 128, 128, 6);
i += 100;
}
//stop rendering
spriteobj->End();
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}[/cpp]
It [I]does[/I] render two, but obviously at the same time, speed, and relative to each other. I want to know how to make two [I]separate[/I] sprites, which leads on to the next example:
2. Building on the previous example, now modify the project so that each explosion is animated at a random animation rate.
I'll try to do that one once you guys tell me how to draw two at once, because I know how to change the rate. I have a feeling I don't really understand the draw and animate functions.
Hey guys, I know this comes up time and time again but can anyone recommend me a good program for screen capture? It has to capture audio through speakers too and sync it properly with the audio. And higher the quality of the capture the better. Almost every program I found either drops frames, messes up the audio capture or produces shit quality captures. I am writing a music visualizer so audio/video sync is very important in captured videos.
Thanks a lot!
Halp! Quack!
I need to make a program in C!
It takes a file that's formatted into NAME|ADDRESS|STUFF|MORE STUFF|ETC|Q|TH|FS|SHIT
And puts each segment of data into an array. I was able to use a tokenizer to split up the string into separate strings, but I dunno if it's putting it into the array properly... I've got a 2D array (char data[9 (segments of data in a line)][100]). I've got data[counter][0] = sscanf("%s", inputString). How can I check this? I'm using printf("%s", data[counter][0]) right after, but the compiler's expecting a decimal rather than a string...
[QUOTE=RoflKawpter;37902006]Halp! Quack!
I need to make a program in C!
It takes a file that's formatted into NAME|ADDRESS|STUFF|MORE STUFF|ETC|Q|TH|FS|SHIT
And puts each segment of data into an array. I was able to use a tokenizer to split up the string into separate strings, but I dunno if it's putting it into the array properly... I've got a 2D array (char data[9 (segments of data in a line)][100]). I've got data[counter][0] = sscanf("%s", inputString). How can I check this? I'm using printf("%s", data[counter][0]) right after, but the compiler's expecting a decimal rather than a string...[/QUOTE]
Not sure if I'm getting this correctly but if yes, then data[counter][0] will return an integer and not a string (specifically, a char).
By the way, you really need to read documentation when programming. How you're using sscanf makes no sense, fix that first and try it on a single string to confirm that it works before you move on to making this work in a 2d array.
I got my old problem "fixed up". It seems to happen intermittently. Got a new one for ya.
Regarding C++, does anyone here have an idea on how to take a string and turn it into a two-dimensional array? For instance, let's take a string that looks like this, minus the quotes and delimiters, which in this case would probably be '\n'.
0 1 2 3 4 5
1 2 3 4 5 6
2 3 4 5 6 7
3 4 5 6 7 8
4 5 6 7 8 9
5 6 7 8 9 0
Then we'll turn it into something like, string[row][column], where if I would type in string[3][4] I would get 5.
I think I figured it out. I pretty much did
strcpy(data[counter], charPtr);
and it worked.
Thanks for the help :)
[QUOTE=elevate;37904748]I got my old problem "fixed up". It seems to happen intermittently. Got a new one for ya.
Regarding C++, does anyone here have an idea on how to take a string and turn it into a two-dimensional array? For instance, let's take a string that looks like this, minus the quotes and delimiters, which in this case would probably be '\n'.
0 1 2 3 4 5
1 2 3 4 5 6
2 3 4 5 6 7
3 4 5 6 7 8
4 5 6 7 8 9
5 6 7 8 9 0
Then we'll turn it into something like, string[row][column], where if I would type in string[3][4] I would get 5.[/QUOTE]
Stringstreams and stoi/stoui can get integers from strings. Stringstreams are cleaner and less prone to fuck-ups though. The << and >> operators automatically format input/output, it's like magic!
[QUOTE=Fetret;37901594]Hey guys, I know this comes up time and time again but can anyone recommend me a good program for screen capture? It has to capture audio through speakers too and sync it properly with the audio. And higher the quality of the capture the better. Almost every program I found either drops frames, messes up the audio capture or produces shit quality captures. I am writing a music visualizer so audio/video sync is very important in captured videos.
Thanks a lot![/QUOTE]
Either Camstudio, VLC or VirtualDub but VirtualDub sucks at recording (still, sometimes it's enough)
[editline]oops[/editline]
Aw forgot about audio recording, never actually used it sorry
I'm wanting to write a 2D game at the moment, and I'm deciding between languages. I could write it in C++, of course. Other than that, would Haskell a viable alternative for game development? I already know both of the languages about equally well. I would prefer Haskell over C++ just because of its pure functionality and terse syntax, but I don't know if there's something in Haskell which makes it entirely unviable as a game programming language.
[QUOTE=ArgvCompany;37911024]I'm wanting to write a 2D game at the moment, and I'm deciding between languages. I could write it in C++, of course. Other than that, would Haskell a viable alternative for game development? I already know both of the languages about equally well. I would prefer Haskell over C++ just because of its pure functionality and terse syntax, but I don't know if there's something in Haskell which makes it entirely unviable as a game programming language.[/QUOTE]
Please go with C++
[QUOTE=Richy19;37911059]Please go with C++[/QUOTE]
What's your argument for that?
[QUOTE=ArgvCompany;37911075]What's your argument for that?[/QUOTE]
There are many more resources for it
Im guessing it will be much faster
[QUOTE=Richy19;37911101]There are many more resources for it
Im guessing it will be much faster[/QUOTE]
What kinds of resources are you talking about here?
[QUOTE=ArgvCompany;37911075]What's your argument for that?[/QUOTE]
Much more in the way of libraries and code that you can reuse.
[QUOTE=ArgvCompany;37911114]What kinds of resources are you talking about here?[/QUOTE]
[QUOTE=ECrownofFire;37911125]Much more in the way of libraries and code that you can reuse.[/QUOTE]
This pretty much, as well as general articles or answered questions
I want to learn Assembly, but im not sure where to start, at all.
There seems to be quite an amount of diffrent assemblers, and i dont know which is the better one to start with. I used to do stuff with the CPU tool in Wiremod, so i got interested in actual assembly, so i wanted to learn.
Got another question regarding it though, i dont know what assembly really can be used for, i mean, in wiremod, its pretty much everything. I cant seem to find any actual answer, but can it do stuff such as, for example, C can? If not, maybe it'd be better if i learnt something else.
Anyone recommend a good 2D graphics library for C++? I know of SDL but there was another one commonly mentioned around that I can't remember the name.
[editline]4th October 2012[/editline]
[QUOTE=.apex;37912231]I want to learn Assembly, but im not sure where to start, at all.
There seems to be quite an amount of diffrent assemblers, and i dont know which is the better one to start with. I used to do stuff with the CPU tool in Wiremod, so i got interested in actual assembly, so i wanted to learn.
Got another question regarding it though, i dont know what assembly really can be used for, i mean, in wiremod, its pretty much everything. I cant seem to find any actual answer, but can it do stuff such as, for example, C can? If not, maybe it'd be better if i learnt something else.[/QUOTE]
Assembly is the most basic level of computer instructions, so yes it can do stuff like C or any other language can, except you have way more control (and way more work too) over what happens, and way more work as well, it's essentially telling the CPU every step of what it has to do, what more complex programming languages do is convert the code you write into assembly so that it can be compiled.
[QUOTE=DeanWinchester;37912815]
Assembly is the most basic level of computer instructions, so yes it can do stuff like C or any other language can, except you have way more control (and way more work too) over what happens, and way more work as well, it's essentially telling the CPU every step of what it has to do, what more complex programming languages do is convert the code you write into assembly so that it can be compiled.[/QUOTE]
Thanks for the answer, still need another answer though, which assembler should i go with..? There are still a bunch of diffrent ones. I dont know if i should choose nasm, masm, yasm or something else really..
[QUOTE=DeanWinchester;37912815]Anyone recommend a good 2D graphics library for C++? I know of SDL but there was another one commonly mentioned around that I can't remember the name.[/QUOTE]
SFML?
[QUOTE=.apex;37913070]Thanks for the answer, still need another answer though, which assembler should i go with..? There are still a bunch of diffrent ones. I dont know if i should choose nasm, masm, yasm or something else really..[/QUOTE]
Inline assembly with a C compiler unless you absolutely like to torture yourself
[QUOTE=Chris220;37913240]SFML?[/QUOTE]
Thanks, that was it!
[QUOTE=Meatpuppet;37901111]Can someone help me?
I'm going through a DirectX book, this is the "on your own" part of the Drawing and Animating Sprites chapter.
Here is my code.
Sprite Draw and Animate Functions:
[cpp]
void Sprite_Draw_Frame(LPDIRECT3DTEXTURE9 texture, int destx, int desty, int framenum, int framew, int frameh, int columns)
{
D3DXVECTOR3 position((float)destx, (float)desty, 0);
D3DCOLOR white = D3DCOLOR_XRGB(255, 255, 255);
RECT rect;
rect.left = (framenum % columns) * framew;
rect.top = (framenum / columns) * frameh;
rect.right = rect.left + framew;
rect.bottom = rect.top + frameh;
spriteobj->Draw(texture, &rect, NULL, &position, white);
}
void Sprite_Animate(int &frame, int startframe, int endframe, int direction, int &starttime, int delay)
{
if((int)GetTickCount() > starttime + delay)
{
starttime = GetTickCount();
frame += direction;
if(frame > endframe) frame = startframe;
if(frame < startframe) frame = endframe;
}
}
[/cpp]
Rendering function:
[cpp] if (d3ddev->BeginScene())
{
spriteobj->Begin(D3DXSPRITE_ALPHABLEND);
Sprite_Animate(frame, 0, 29, 1, starttime, 1);
Sprite_Draw_Frame(explosion, 200, 200, frame, 128, 128, 6);
//stop rendering
spriteobj->End();
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}
if (d3ddev->BeginScene())
{
spriteobj->Begin(D3DXSPRITE_ALPHABLEND);
int i = 0;
while(i < 200)
{
Sprite_Animate(frame, 0, 29, 1, starttime, 1);
Sprite_Draw_Frame(explosion, 200 + i, 200 + i, frame, 128, 128, 6);
i += 100;
}
//stop rendering
spriteobj->End();
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}[/cpp]
1. The Animate Sprite project in this chapter does show how animation works, but it's kind of a boring demo. Modify the program so that it generates more than one explosion sprite at a time.
I did do that, but not the way it intended. I just did this:
[cpp] if (d3ddev->BeginScene())
{
spriteobj->Begin(D3DXSPRITE_ALPHABLEND);
int i = 0;
while(i < 200)
{
Sprite_Animate(frame, 0, 29, 1, starttime, 1);
Sprite_Draw_Frame(explosion, 200 + i, 200 + i, frame, 128, 128, 6);
i += 100;
}
//stop rendering
spriteobj->End();
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}[/cpp]
It [I]does[/I] render two, but obviously at the same time, speed, and relative to each other. I want to know how to make two [I]separate[/I] sprites, which leads on to the next example:
2. Building on the previous example, now modify the project so that each explosion is animated at a random animation rate.
I'll try to do that one once you guys tell me how to draw two at once, because I know how to change the rate. I have a feeling I don't really understand the draw and animate functions.[/QUOTE]
Reposting for new page. I really need to understand this.
Does anyone know how to get the BOOST_ROOT environment variable working? I've set it to the root directory of my Boost C++ libraries (where I extracted them), and I can echo it in the console.
But when I try to do this:
[quote] b2 --with-thread --with-date_time --build-type=complete[/quote]
It says b2 is invalid, etc etc. I've built the boost executables using the bootstrap and they are in the directory. (Visual studio can't find the source either, and it also uses the environment variable.)
Has anyone else used Boost and had this issue?
EDIT: Okay, One, I forgot to CD to the right directory with b2. And two the redlining in Visual studio is just a microsoft product being a microsoft product. Problem self solved guys!
I've recently started learning C++ with the help of a book (C++ Primer Plus) and online resources. I think I have a few of the basic things under control, so I began doing some beginner exercises that I found [url=http://www.cplusplus.com/forum/articles/12974/]here[/url]. I managed the first few without a problem, including the bonus parts, but I'm stuck on the bonus for the 'Pancake Glutton' exercise.
The part I'm stuck on is:
[quote]★★★★ Modify the program so that it outputs a list in order of number of pancakes eaten of all 10 people.
i.e.
Person 4: ate 10 pancakes
Person 3: ate 7 pancakes
Person 2: ate 4 pancakes
Person 1: ate 1 pancakes
Person 5: ate 0 pancakes[/quote]
The amount of pancakes each person ate is user-defined, and stored in an array called people. I can't figure out a way to analyze the data and sort it like that, without having 25 if statements in the vein of:
[CODE]if(people[0] > people[1] && people[1] > people[2] ...)[/CODE]
So are there any easy (or at least compact) ways to do this?
[QUOTE=Angush;37919490]I've recently started learning C++ with the help of a book (C++ Primer Plus) and online resources. I think I have a few of the basic things under control, so I began doing some beginner exercises that I found [url=http://www.cplusplus.com/forum/articles/12974/]here[/url]. I managed the first few without a problem, including the bonus parts, but I'm stuck on the bonus for the 'Pancake Glutton' exercise.
The part I'm stuck on is:
The amount of pancakes each person ate is user-defined, and stored in an array called people. I can't figure out a way to analyze the data and sort it like that, without having 25 if statements in the vein of:
[CODE]if(people[0] > people[1] && people[1] > people[2] ...)[/CODE]
So are there any easy (or at least compact) ways to do this?[/QUOTE]
You're going to want to look into [URL=http://en.wikipedia.org/wiki/Sorting_algorithm#Comparison_of_algorithms]sorting algorithms[/URL]
-snip fixed it-
In OpenGL, if I have two shaders, a lighting and a texturing shader for example, how would I go about combining the output of those 2 shaders?
And I'm not talking about merging the code into a single shader, I actually want to keep those shaders seperated.
A small example:
[thumb]http://puu.sh/1bBO1[/thumb]
As you can see I've got the lighting rendered in the main view, and the textures are rendered in the smaller viewport. I wish to combine these two into a single view having both textures and lighting.
I'd appreciate any help!
Hi everyone, first time posting here.
I am going back to school to learn CS and my first programming class is a intro to JAVA class. My teacher is absolutely horrendous at teaching. He isn't concise and doesn't explain things clearly. He is also a mumbler.
I have a HW assignment on Loops and im completely lost.... I'm hoping you guys can help me out.
The assignment :
Complete the program named GetVowels below so that it reads in a string, finds all the vowels in that string, and prints out the vowels.
For example, given the input string of "Hello, World!", the program should print the string "eoo".
/**
Reads a string and prints out all vowels contained in that string.
Vowels are A E I O U a e i o u.
Input: the value of s, a string
Output: a string containing all the vowels in s,
in the order in which they appear in s
*/
Here is what I have so far...
java import.util.Scanner;
public class GetVowels
{
public static void main(String[] args)
{
String r = "";
Scanner in = new Scanner(System.in);
String s = in.nextLine();
System.out.println(r);
}
}
I have absolutely no idea where to go from here.
[QUOTE=GhostxNote;37920959]Hi everyone, first time posting here.
I have absolutely no idea where to go from here.[/QUOTE]
Well you want to take s and loop throught it:
Then check if that letter is a vowel and add it to r if it is.
In pseudo code
[java]
foreach letter l in s:
if l is in "aeiou":
r += l;
[/java]
Protip: when posting code use
[B][noparse][code][/code][/noparse][/B]
for general code:
[code]
this is some code
[/code]
for specific language:
[B][noparse][cpp][/cpp]
[csharp][/csharp]
[java][/java][/noparse][/B]
[cpp]
this is some code
[/cpp]
Sorry, you need to Log In to post a reply to this thread.