moving ground terrain - problem accesing struct

This is a discussion on moving ground terrain - problem accesing struct within the Game Programming forums, part of the General Programming Boards category; hi all i'm doing a game now by the name of galatea for my APCG coursework and i'm kinda stuck ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    2

    moving ground terrain - problem accesing struct

    hi all

    i'm doing a game now by the name of galatea for my APCG coursework and i'm kinda stuck in rendering the moving ground terrain part. The game is composed of three major parts namely
    GameInit
    GameMain
    GameShutDown
    I created 200 buildings in the game init part and have stored all the attribs in a struct data type. Problem is i can't access the struct draw() functions from GameMain where it is the part that game runs like kinda looping 50 times in a sec i think. I think I throughly settled the mechanics part but its only the problem accesing. It seems my struct needs to be global or somethin but i dunno how.


    My declarations can be seen above. The 'structure' struct as some of u might already know, is unrecognised in Game MAin. Please do not ask me to revert to classes cos my instruction guide says use the struct. Then again, how do u create 200 instances of the building just like i have done with struct, if u can teach me i would be most happy. Thanks n have a nice day ppl


    Nick
    Code:
    Code:
     struct Building{ double xcoordinate; double ycoordinate; double wide; double height; RECT destRect1, sourceRect1; int type; void draw(); ]; Building structure [200];

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    I'm not sure of your setup but to move the terrain translate it towards the camera.

    In other words if the camera has a velocity vector of 0,0,10 then translate all terrain vertexes by 0,0,-10.

    Translate the world by the negated vector of the camera. This way the world moves toward the camera- or at least in exact relation to the the camera is doing.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    2
    ok tis is bad , i seriously dunno wat ure talking about...like i said, i already got the mechanics figured, the only problem is with accessing the draw function from GameMain.....i dunno how to make the function call from across the section. anyways thanks 4 ur help

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Well for me to see the structure of your class hierarchy you will have to posts some key snippets of code so I can help you.

    But to move the terrain my statement was correct. Terrain is created by vertexes at varying heights. Normally all terrain quads and triangles are the same size; it is only their y component that is different thus creating hills and valleys. To move the terrain you would translate those vertexes relative to the viewer or camera. Like driving down the road - you are moving forward but everything outside is moving towards you or backwards thus the negative vector.

    Translate(-player.x,-player.y,-player.z)

    Please post code so we can help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with struct?
    By cangel in forum C Programming
    Replies: 8
    Last Post: 09-27-2008, 11:35 PM
  2. Help with a Struct problem :)
    By yrostran in forum C Programming
    Replies: 11
    Last Post: 05-09-2006, 02:14 PM
  3. very weird problem (pointers I think)
    By hannibar in forum C Programming
    Replies: 2
    Last Post: 10-11-2005, 06:45 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 05:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21