C++ :: Mapping In The Loop?
Aug 1, 2013
Is it possible to let the map on a loop and map different string with different vectors? It means that have a conceptual loop as following.
for(i=0, i=10, i++)
map< string_i, vector<int> > myVectors_i;
View 1 Replies
ADVERTISEMENT
Jun 6, 2013
void create_map(){
int x = 0;
int y = 0;
while (y >= 15) {
game_map[x][y].pos_x = x * tile_size;
game_map[x][y].pos_y = y * tile_size;
Objective of the code: to loop through all tiles in the game, setting their X and Y coordinates.
It just doesn't do anything at all. No error message.
View 12 Replies
View Related
May 27, 2013
I have a problem with implementing Shadow Mapping into a project I am working on. I am very much new to shaders and I have been given a Shadow Mapping shader to implement and understand. I have mostly got my head round the concept and the code but I can't figure out why its not working.
As I understand it the main steps to follow are;
1) Render the scene from the POV of the light - this is done in ShadowMap::SetUpDepthRender where the view and projection matrices are passed to the shader.
2) Render all objects in the scene - this creates a shadowmap (depth map) via the shader.
3) Reset the view and projection matrices to that of the camera - done in ShadowMap::SetUpSceneRender.
4) Render the scene objects once more appling the depth map to them via the second pass of the shader.
The problem Im having is that I have a stripe of light running diagonally across the screen. It passes through the point of the spotlight that I am mapping for. I believe this is the shadowmap being applied to the scene however I could be wrong?
Below is the code in the ShadowMap class used for setting the fx file.
LPDIRECT3DSURFACE9 oldDepthSurface = NULL;
LPDIRECT3DSURFACE9 oldRenderTarget = NULL;
ShadowMap::ShadowMap(void) {
//Create our Light
Vector3D lightPosition(20.0f, 2.9f, 10.0f);
Vector3D lightDirection;
[Code] .....
View 2 Replies
View Related
Dec 12, 2013
I'm very very new to maps and am really just trying to hash them out by myself.
If you're mapping strings to integers:
map <string, int> myMap;
myMap[ "zero" ] = 0;
myMap[ "one" ] = 1;
How do I print the string "zero", for instance, from myMap?
cout << myMap.at(0) << endl;
doesn't work. Nor does:
cout << static_cast<string>( myMap.at(0) ) << endl;
I need access to the string using the int and the int using the string. Or just direct access to one or the other. . . It's just confusing that they're technically mapped to one another but I can't really access either of them.
View 4 Replies
View Related
Jan 21, 2014
So I'm rewriting an old project of mine, and I'm trying to determine if there's truly any better way to map the data taken from a text file "dictionary" into the correct class fields for further processing. For example:
FNAME=MY_FIRST_NAME
ADDR=123 SOMEWHERE LN, NOWHERESVILLE, TX 01234
LNAME=MY_LAST_NAME
TOTCALLS=47
In each of these, I'd need the "value" (MY_FIRST_NAME, MY_LAST_NAME, etc) from the "keys" (FNAME, LNAME, etc) to be mapped to the proper class fields. Say, for example, I had this:
Class DataProcessing {
public string Address;
public string FirstName;
public string LastName;
public int TotalCalls;
...
}
I would need DataProcessing.Address to be set to the value in the ADDR key/value pair. The same would be true for each other field. The problem is that based on the text file's source (which isn't under my control, and won't be changed anytime soon), the key/value pairs are not always in the same place...so a second file could have the data as such:
TOTCALLS=47
ADDR=123 SOMEWHERE LN, NOWHERESVILLE, TX 01234
LNAME=DARKPOETCC'S LAST NAME
FNAME=DARKPOETCC'S FIRST NAME
Any smarter way to do this than looping through each line that was read in from the file, and determining where it belongs, such as (pseudo code follows):
IF FieldName == "TOTCALLS" THEN
//Assign to TotalCalls field
ELSEIF FieldName == "ADDR" THEN
//Assign to Address field
ELSEIF FieldName == (You get the picture...)
//Do thing N_Field
View 9 Replies
View Related
Sep 26, 2012
How to measure a NAS (NTFS) free space/total space and used space? Few more details: I have the needed code to map the NAS location (serverNameshared_folderfoldersub_folder) into the local server where I am running my applciation but I can only get the needed statistics above for the whole NAS, I need to know the statistics for a specified folder on the NAS, how can I do that?
View 1 Replies
View Related
Oct 13, 2014
We are making a program--but every time we input a value for scanf, the following for loop does not work and the program quits without displaying the for loop's function. We are not getting any errors.
View 11 Replies
View Related
Feb 15, 2015
I have tried to submit this topic before but i didn't submit my whole code and it was removed. So here it is. All I am trying to do is load form2 from form1 then back to form1 from form2 for a certain number of times the get out of the loop. I am new to C-Sharp and it seems as though I cant seem to figure out a way to do this.
Here is form1 and form2 code. I have commented out a few things I have tried.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
[Code]....
View 3 Replies
View Related
Jul 1, 2013
Code:
#include <stdio.h>
#include<ctype.h>
void try5t(){
char choice;
int choiceint;
[Code] .....
Loop is repeated an additional time as shown in the screenshot:
View 9 Replies
View Related
Feb 20, 2014
Given a for loop:
int i;
for(i = 0; i < 1000; i++)
;
How many nanoseconds, or microseconds or milliseconds does it take for each iteration? And why do some use it as a timer mechanism?
View 3 Replies
View Related
Apr 19, 2014
I already made a nested for loop into a while loop (below this) and now I'm trying to make the outer for loop into a do while loop, but it's not working.
#include <iostream>
using namespace std;
int main () {
int len;
int j;
int i;
[Code]....
And I can't make this code do the same thing. It stops after one loop, instead of continuing to the end. Why won't the loops continue?
#include <iostream>
using namespace std;
int main(){
int len;
cout << "Enter a number: ";
[Code] ....
View 2 Replies
View Related
Mar 25, 2012
I need to convert the following while loop:
count = 1;
while (caloriesForItem != 0, count != numberOfItems )
{
cout<<"Enter the calories: ";
cin >> caloriesForItem;
totalCalories += caloriesForItem;
count++;
}
This is what I have come up with:
totalCalories += caloriesForItem;
for (count = 1; caloriesForItem != 0; count != numberOfItems)
{
cout<<"Enter the calories: ";
cin >> caloriesForItem;
count++;
cout << "Total calories eaten today = " << totalCalories << endl;
}
However the output is not the same?
View 6 Replies
View Related
Sep 25, 2014
I for the life of me can't get my logic straight. I have 2 lists, 1 a list of text, and the other a list of int.
Here's my main list: List<string> ListNeedToADD = ListOfSPSExt.Except(ListOfReportExt).ToList();
Here's my second list:IEnumerable<int> result2 = Enumerable.Range(1, Convert.ToInt32(myValue)).Except(hostList);
I need to loop through my main list, ListNeedToADD, and for each item in that list, grab 1 value from the 2nd list and send those 2 items to a method. Something like this:
foreach (string myString in ListNeedToADD)
{
foreach (var item in result2)
{
intSort = item;
insertReportLimits(attribTable, myString, intSort, con);
}
}
The problem with doing it the way I am above is it loops through ALL the items for each myString.
For my method, it needs to look like this: insertReportLimits(attribTable, "34257", 22, con); then it would move on to the next: insertReportLimits(attribTable, "34854", 27, con); etc etc.
View 4 Replies
View Related
Feb 22, 2015
I can't get out of my loop to fill the array. This array should stop and print after 10 inputs. but it keeps asking for input.
This is what my code is supposed to do. Use 0 as sentinel for an array. Only positive ints will be entered into the array. A negative int should result in an error message, then input will continue. The numbers will be inserted into the array in ascending order. Do not insert them then sort the array.
#include <iostream>
#include <cmath>
using namespace std;
const int arraySize =10;
[Code].....
View 4 Replies
View Related
Apr 16, 2013
I am using a for loop to count down from 10 to 0 it's working to count down from 10 to 1 but when the program cames to the 0 then the program freezes by any reason.
Code:
#include <iostream>
using namespace std;
int main()
{
int number[2];
cout << "Enter number: ";
cin >> number[0];
if (number[0] == 1)
[Code] ....
View 11 Replies
View Related
Nov 8, 2013
Is there a way to end a loop ?
Code:
while ( menuopt == 1)
{
printf("Lets start
");
printf("12 x 4 = ?
");
[Code] ....
View 2 Replies
View Related
Mar 1, 2013
What I need to do to get rid of the infinite loop?
Code:
do {
printf("Enter the number of tests:");
scanf("%d", &test);
if (test< 0 || test> 4)
printf("Wrong number. Please try again!
");
}
while (test< 0 || test>4);
View 9 Replies
View Related
Apr 17, 2014
So I have a programming assignment.
Code:
#include <stdio.h>
int main(void)
{
int input;
int sum;
int i;
int t;
[Code] .....
So you input an integer ex) 30
the printing of t =(i+i)+1 and i++ is carried out until i=30, which is when the sum of all the t's is printed.
If the value you entered is not an integer, the loop ends.
I'm supposed to do this with one while loop, and no more. I can't use the for loop either.
How can I do this?
View 7 Replies
View Related
Jul 21, 2013
is it possible to output like this using only one loop? if yes, how?
target output Code: ABCDE
EDCBA here is my code but using one loop im not getting my target output Code: #include <stdio.h>
main()
{
int x, y;
for(x='a', y='e'; x<='e'; x++, y--)
{
printf("%c
%c", x, y);
}
getch();
}
View 6 Replies
View Related
Nov 16, 2013
I have a while loop that will not disengage when the input given as "exit".
Code:
while (orders != "exit"){
for (i=0;i<25;i++){
for (j = 0; j<50;j++){
if (i == x && y == j){
printf("H");}
else {
printf("%c", map[i][j]);}
[Code]....
View 1 Replies
View Related
Dec 6, 2013
I'm trying to create a connect four game, but I've ran into a problem while trying to read valid user input.
Code:
// 4 in a row game
#include <stdio.h>
#include <stdlib.h>
#define NUM_ROWS 6
#define NUM_COLS 7
}
[code]...
If the user enters an invalid number, then it works fine, but if a character is entered, the while loop in main never breaks.
View 9 Replies
View Related
Feb 6, 2013
I'm writing a program to sum up the even numbers in between 1 and 100, using a while loop. At the beginning of my program, I initialize a variable "sum" to 0, and a variable "temp" to 1. Afterwards I enter a loop where I determine if "temp" is even or not, and if so add it to sum. However, at the end of my program, when I print "sum", I get a result of 0. Below is my code.
Code:
#include <stdio.h>
int main(void)
{
int sum = 0, temp = 1;
}
[code]...
View 4 Replies
View Related
Nov 24, 2013
Why my if statement for argc <3 will not execute? as the one for argc >3 does...
Code:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]){
int i;
int fnlength = strlen(argv[2]);
char *namein = argv[2];
int j = (fnlength-1);
char input[100000];
}
[code]....
View 2 Replies
View Related
Feb 19, 2015
While trying to redo everything in c i have an error on a do while loop and i don't understand i've corrected everything else but i don't understand why the error occurs even though it says how to fix it it says error expected ) before token -line 18 part of code
Code:
int main(){
Beep (523,1000); // sound at 523 hertz for 1 000 milliseconds
char cPresent;
do
}
[code]....
this is just extra bits i've added on to the assignment but I've worked on the c++ code for a week now i have less than a day to redo it
View 2 Replies
View Related
May 11, 2013
This is an example from C++ Primer on while loops shortened for simplicity:
int main() {
int value = 0;
while(cin >> value) cout << value;
return 0;
}
When I compile and run the above code the program keeps asking for input after I input nothing but pressing ENTER no matter how many times. The only way I can get it to stop asking for input is to input something other than an int such as a char or string. Program executes as intended after that. I have googled this issue and read all seemingly relevant results and nothing seems to pertain to my exact problem. I think it may have something to do with my computer's own settings or something and am baffled as to what it may be.
View 10 Replies
View Related
Mar 2, 2014
I need to write a complete program using "While Loop" to calculate 1! to 12! using just "int" variables. Only from 1 to 12 and there are no other inputs.. This is my first time using While loop.
View 2 Replies
View Related