About Store Forum Documentation Contact



Post Reply 
Missing something?
Author Message
Nemesis213 Offline
Member

Post: #1
Missing something?
So I am very new to both esenthel and visual studio... Sorry for the (probably) dumb question. Basically I have compiled ran a few tuts, I have made projects in esenthel and created vs projects using the copy/paste method described in the wiki. All was fine until I tried to run the terrain tut which uses macros for looping... I have removed/added code in many ways but cannot get any while/for loop to compile?!? ...it's like the compiler doesn't even know what it is... The error i get says I'm missing a ; before { ....but this isn't correct. Am I missing somthing simple with my project's configuration? If someone could point me in the right direction i would be very appreciative smile
03-21-2013 02:26 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #2
RE: Missing something?
Could you paste the code where it goes wrong perhaps?
03-21-2013 02:32 PM
Find all posts by this user Quote this message in a reply
Nemesis213 Offline
Member

Post: #3
RE: Missing something?
I can tonight when I get home but its anywhere i put a loop... I've tried many simple variations of this:

i= 1
while(i < 5){i++;}

Any many other variations of while/for loops just to test...
Compiling always fails at while. Says I'm missing ; before {

the hello world tut compiles just fine :/
03-21-2013 03:26 PM
Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #4
RE: Missing something?
int i = 0; (don't forget the ";")
while (i < 5) { i++; }
03-21-2013 03:33 PM
Find all posts by this user Quote this message in a reply
Nemesis213 Offline
Member

Post: #5
RE: Missing something?
I didnt that was a typo sorry... The variables are declared much before the while loop... I'm positive it's the while statement. I think something is wrong with my configuration but I have no idea where to look :( I've googled and looked through files and the wiki but cant find anything like my problem nor have I ever experienced it before although my experience with coding is limited to code::blocks in windows and makefikes and text editors in Linux.... I'm very new to esenthel and visual studio :(
03-21-2013 04:29 PM
Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #6
RE: Missing something?
You'll probably want to paste a bit more code here. smile
The way you have it there, you would get an infinite loop too.
03-21-2013 04:33 PM
Find all posts by this user Quote this message in a reply
Nemesis213 Offline
Member

Post: #7
RE: Missing something?
Ill paste it tonight i guess... Literally I am inserting that while statement into the hello world tut. ...and I don't see an infinite loop? It should only loop five times :/ ami forgetting somthing? I havnt messed with code in a couple years....

But again, ill post the code later. Although its just the hello world tut with that while loop pasted into it... it compiles fine without any while/for loops :(
03-21-2013 05:35 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #8
RE: Missing something?
remember that it isn't running infinite amounts if it is inside the update function
Code:
bool update(){
int i= 1;
while(i < 5){
LogN(S+i);
i++;
}
return true;
}
will make it rerun every frame.

eg in the case above it will log
1,2,3,4 continiously as it is set each frame.
Code:
bool update(){

static int i= 1;
while(i < 5){
LogN(S+i);
i++;    
}
return true;
}
or

Code:
int i= 1;
bool update(){

while(i < 5){
LogN(S+i);
i++;
}
return true;
}
Will make the while loop run once
(This post was last modified: 03-21-2013 06:37 PM by Zervox.)
03-21-2013 05:50 PM
Find all posts by this user Quote this message in a reply
Nemesis213 Offline
Member

Post: #9
RE: Missing something?
Ohhhh that makes much sense. Thank you very much! I likely may have done that.... I'm anxious to get home from work and see smile

Anyways thank you all for the help and surprisingly quick responses!
...seems to me a very helpfull community smile
03-21-2013 05:54 PM
Find all posts by this user Quote this message in a reply
Nemesis213 Offline
Member

Post: #10
RE: Missing something?
well unfortunately that wasnt my problem :(
here is an example of what compiles if i remove the while loop....

Code:
/******************************************************************************/
#include "stdafx.h"
/******************************************************************************/
Actor ballActor;

PhysBody ballphys;
Mesh ballMesh;

Flt size;

int i = 0;
/******************************************************************************/
void InitPre()
{
    App.name(L"PlanetTest1");
    App.flag=APP_MS_EXCLUSIVE;
    Paks.add(L"../../Data/engine.pak");
    D.sync(true);
}
   int x1, y1 = 1;
     while(x1 < 128) {
        if(y1 == 128){
            x1++; y1 = 1;
         }
        y1++;
   }
  
Bool Init()
{
    Cam.dist=4;
    size = 2.0f;

    ballMesh.parts.New().base.create(Ball(size),VTX_TEX0|VTX_NRM);
    ballMesh.setMaterial(Materials.ptrRequire(L"../../Data/Mtrl/Grass/0.mtrl")).setRender().setBox();    

    return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
    if(Kb.bp(KB_ESC))return false;
    CamHandle(0.1f,10,CAMH_ZOOM|CAMH_ROT);
}
void Render()
{
    switch(Renderer())
    {
    case RM_PREPARE:
        {
            ballMesh. draw(ballActor.matrix(), ballActor.vel(),ballActor.angVel());

            LightPoint(20,Vec(0,3,-3)).add();
        }break;  
        
    }
}
void Draw()
{
    Renderer(Render);
}

and this is the error i get in visual studio 2008
Code:
1>------ Build started: Project: Tutorials, Configuration: Debug Win32 ------
1>Compiling...
1>00 - Start.cpp
1>c:\users\nemesis\desktop\eeproject\source\00 - start.cpp(31) : error C2059: syntax error : 'while'
1>c:\users\nemesis\desktop\eeproject\source\00 - start.cpp(31) : error C2143: syntax error : missing ';' before '{'
1>c:\users\nemesis\desktop\eeproject\source\00 - start.cpp(31) : error C2447: '{' : missing function header (old-style formal list?)
1>Build log was saved at "file://c:\Users\Nemesis\Desktop\EEproject\Debug\BuildLog.htm"
1>Tutorials - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

any thoughts?
03-22-2013 12:11 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #11
RE: Missing something?
Your entire while statement isn't inside a function. You're just hanging it out in the wind somewhere. lol Put it inside update(), or init(), wherever you need it.

On a side note, you are not initializing x1 to anything, so undefined behaviour beyond this point.
03-22-2013 01:31 AM
Find all posts by this user Quote this message in a reply
Nemesis213 Offline
Member

Post: #12
RE: Missing something?
Thank you for that... I see what you mean lol. Sorry I'm used to some easier 2D libs... I'd say I'm used to my old main() function, but that was quite the blunder on my part. Thanks for bearing with me and not criticizing smile ..I have used some simple 2D graphics libs before, but a full engine like this is a first for me and I was trying to experiment as i went pfft

Ill try that and see where I get smile again thanks for all the help smile

also I was always under the impression that: int x,y,z = 0 initialized them all? guess I'm wrong?
(This post was last modified: 03-22-2013 01:50 AM by Nemesis213.)
03-22-2013 01:48 AM
Find all posts by this user Quote this message in a reply
Post Reply