Jump to content
  • Advertisement

marrshal

Member
  • Content Count

    16
  • Joined

  • Last visited

Community Reputation

108 Neutral

About marrshal

  • Rank
    Member
  1. I'm implementing a simple particle system. I draw a textured polygon where the particle is suposed to be. This texture has a transparent regions (in the edges). Here is the problem: [attachment=7397:scr.JPG] As you can see the in the transparent regions is draw the backround, not the part of the particle behind. During the rendering of the fountain I didn't disable depth testing or something similar. Thanks in advance!
  2. marrshal

    Drawing near objects problem

    What toolkit are you using to create your window/OpenGL context? Depth buffer precision has to be specified as you create the context. [/quote] This helps, I was using 16 bit depth buffer.
  3. marrshal

    simple c++ project

    Well, my first attempts to make a game was a very simple game in the good old console. Actually it was a snake game.. You can use this void clear_screen (){ DWORD n; DWORD size; COORD coord = {0}; CONSOLE_SCREEN_BUFFER_INFO csbi; /* Get a handle to the console */ HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE ); GetConsoleScreenBufferInfo ( h, &csbi ); SetConsoleCursorPosition ( h, coord ); } to clear you're screen faster (you'll need to #include "Windows.h" ). This is in case you want to write something very simple, very ugly and very unuseful only for fun and practice with the language. The next thing I can suggest you is allegro. Alegro is very simple library for 2D game dev. You can learn it from the net. And you'll something more complex (but still simple ), good looking (i mean with graphics better than in the first suggestion) and cool. (Actually I have started writing Chicken Invaders using Allegro because it looks too bad in the c++ console ) . And my third suggestion is to start with the hardcore - openGL. With openGL you can write very powerful games and will be very usefull if you learn it. But if you just start with c++ it will be very hard for you. My suggestion is to write some bullshits while you get the conception of c++ and gamedev and then openGL will be easier for you. I hope I was helpful!
  4. marrshal

    Drawing near objects problem

    Thank you very much for the answers. I have places near and far dist closer and i have separated the surfaces of the water and the ground, so the water plane and the ground plane are crossing, not overlapping as before. This fix the problem from the viewpoint of the player but if I'm looking with my global camera the problem is still there. @swiftcoder how can I check the bits of depth buffer I'm requesting? Everything I'm doing about my depth buffer is: glEnable (GL_DEPTH); glEnable (GL_DEPTH_TEST);
  5. When I draw object that supose to be realy close to each other I have results like those: [attachment=7027:fail01.JPG] [attachment=7030:fail02.JPG] In this case the water is about 0.1f above the ground in the "problem" area. If I zoom in a lot the problem goes off. And if I zoom out the problem gets at much more areas: [attachment=7029:fail03.JPG] Do you know where the problem comes from? I think is somthing about the depth testing, but still can't fix it.. Thank you in advance!
  6. marrshal

    Rigid body dynamics

    I'm writing a simple physics simulator and I have a problem with dynamics of rigid body. How the body (for example box) rotates and translates when a force (or several forces) are apllied at different points of the body?
  7. marrshal

    Collisions in C++

    In a bitmap this "surface" should be a certain color (if you mean other bitmap will be more complex). So you can use getpixel to get the "[font="verdana, helvetica, sans-serif"]value of the pixel in the color format of the bitmap" and then getr, getg, getb, geta to determine the RGBA color of this pixel. And if this color is gray (the color of the road) your IsRoad func to return true. This will work (I hope) but it isn't the safest solution. It would be better to use a separate texture for the whole road and to color the non-road space into an "unusable" color or in transparent.[/font]
  8. From a couple of weeks I'm having big troubles with the game I'm trying to write. For the models and the animations I'm using 3ds max but I can't use them in my OpenGL game. Actually I have succed to load a model from an .ASE file but loading animation from .ASE is impossible for me. A have found a demo where are loaded .md2 but i can't find reliable exporter... I can't install lib3ds (missing file) and PortaLib3D can't even download (broken links)... I feel I'm going crazy. Please, help me.
  9. marrshal

    Collisions in C++

    Well this is the easiest solution according to me... Can you post your code and the errors?
  10. marrshal

    Collisions in C++

    You shoud have a function like this bool IsRoad(int x, int y); which returns true if is the point (x, y) lies on a road and false otherwise. And in the function which moves the character you should perform a movement only if the player's position after the movement is on road. For example: class Player { int posX, posY; //... void Update() { int newPlayerPosX, newPlayerPosY; if(keyIsPressed['w']) { newPlayerPosX = posX; newPlayerPosY = posY - 1; } if(keyIsPressed['s']) //... //... if(IsRoad(newPlayerPosX, newPlayerPosY)) { posX = newPlayerPosX; posY = newPlayerPosY; } } }; If you load the world as a texture will be hard to write IsRoad function. I think is easier (and faster) to describe the world in a array such as 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 T 0 0 0 0 0 R R R 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 R R R 0 0 0 0 0 0 0 0 0 0 0 0 0 0 H 0 0 0 R R 0 0 0 0 0 0 0 0 0 0 0 R R R R R R R R R R 0 0 0 0 ... ... where 0 is empty space, R is a road, T is a tree, H is a house. And now you should have texture for tree, for house, for road etc. Now the IsRoad func will be: bool IsRoad(int x, int y) { return world[x][y] == 'R'; } Hope I was helpful.
  11. marrshal

    XNA does not draw everything

    I found the problem. Somehow in the middle of the night I decided not to draw [font="Lucida Console"]prop_menu.skin[/font] and I was wondered when I saw all of my small boxes drawn. So, because of the sprite priority first are drawn the "missing" boxes, then prop_menu.skin [font="Arial"]and in the end the "visible" boxes. To fix the problem I should just change[/font] [font="Arial"] spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied); base.Draw(gameTime); spriteBatch.End();[/font] [font="Arial"]int the main Draw func to [/font] [font="Arial"] spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied); base.Draw(gameTime); spriteBatch.End();[/font] [font="Arial"]and reorder some of the draw func calls. [/font]
  12. marrshal

    XNA does not draw everything

    for (int j, i = 0; i < 3; i++) for (j = 0; j < 3; j++) { prop_menu.sBatch.Draw(prop_menu.box_small, prop_menu.position + new Vector2(i * 70 + 20, j * 70 + 160), Color.White); } This generates the positions of all elements. (prop_menu.position is the position of the whole menu)
  13. marrshal

    XNA 4.0 'Keyboard Input' Help

    Well, when you are wondering what a piece of code was doing - delet it and see the difference. When you deletit you'll see if you hold a key it would be drawn many times. This code avoids that. It is very bad formated so it is hard understand it. Look that:[font="CourierNew, monospace"] [/font] //Get pressed keys and display them Keys[] pressedKeys; pressedKeys = keyState.GetPressedKeys(); // work through each key presently pressed for (int i = 0; i < pressedKeys.Length; i++) { //set a flag to indicate we have not found the key bool foundIt = false; //work through each key previously pressed for (int j = 0; j < oldKeys.Length; j++) { if (pressedKeys == oldKeys[j]) { //we found the key in previously pressed keys foundIt = true; //no need to look further break; } } //... } oldKeys are the keys pressed (at the same time) in the last call of Update pressedKeys are the currently pressed keys. First loop "visits" each currently pressed key. The second loop compare the current key from the first loop. When (if) it is found the search stops (that do the break statement if the second loop) and that key is not drawn. Analogeus, if it is not found the key is drawn. Note: When you release all keys pressedKeys is empty and because of that you can draw single letter several times. Hope I was helpful
  14. marrshal

    XNA 4.0 'Keyboard Input' Help

    Change the end of Update to: if (foundIt == false) { //if we get here we didnt find the key in old keys, so // add the key to the end of the message string string keyString = ""; //empty string switch (pressedKeys) { //digits case Keys.D0: keyString = "0"; break; case Keys.D1: keyString = "1"; break; // other keys default: keyString = pressedKeys.ToString(); break; } messageString = messageString + keyString; }
  15. This is simple snake game I wrote when I was learning C++. About the implementation - it could be more object-oriented but I think for a person who would like to see a prehistorical game it'd be ok. I'm not permited to attach the code so I'm posting it: /* * Author: Marin Shalamanov * Date: 14.09.2010 */ #include <iostream> #include <cstdio> #include <fstream> #include <string> #include <ctime> #include <conio.h> #include <queue> #include <windows.h> using namespace std; #define H 30 #define W 30 char scr[H][W]; short int length; short int i, j; short int diff; bool eaten = false; void init(); void print(); void clear_screen (); void intro(); void game_over(); void set_diff(); void main_menu(); void play(); class snake{ public: queue<short int> x; // coordinates of each piece of the snake queue<short int> y; // Yes, it would be better if there was a class Coordinate // but I'm too lazy to rewrite it void init(){ x.push(H/2); y.push(W/2-1); x.push(H/2); y.push(W/2); } void add(){ scr[x.back()][y.back()] = scr[x.front()][y.front()] = 'X'; } //Movements void up(){ if(x.back()==0) game_over(); x.push(x.back()-1); y.push(y.back()); if(scr[x.back()][y.back()] == 'X') game_over(); if(scr[x.back()][y.back()] != 'o'){ scr[x.front()][y.front()] = ' '; x.pop(); y.pop(); }else eaten = true; scr[x.back()][y.back()] = 'X'; } void down(){ if(x.back()==H-1) game_over(); x.push(x.back()+1); y.push(y.back()); if(scr[x.back()][y.back()] == 'X') game_over(); if(scr[x.back()][y.back()] != 'o'){ scr[x.front()][y.front()] = ' '; x.pop(); y.pop(); }else eaten = true; scr[x.back()][y.back()] = 'X'; } void left(){ if(y.back()==0) game_over(); x.push(x.back()); y.push(y.back()-1); if(scr[x.back()][y.back()] == 'X') game_over(); if(scr[x.back()][y.back()] != 'o'){ scr[x.front()][y.front()] = ' '; x.pop(); y.pop(); }else eaten = true; scr[x.back()][y.back()] = 'X'; } void right(){ if(y.back()==W-1) game_over(); x.push(x.back()); y.push(y.back()+1); if(scr[x.back()][y.back()] == 'X') game_over(); if(scr[x.back()][y.back()] != 'o'){ scr[x.front()][y.front()] = ' '; x.pop(); y.pop(); }else eaten = true; scr[x.back()][y.back()] = 'X'; } }sn; int main(){ intro(); main_menu(); return 0; } void main_menu(){ clear_screen(); printf("\n\tMAIN MENU \n \n"); printf("\t1. Start game \n"); printf("\t2. Exit \n"); printf("\n\n \n\t"); short int choice; scanf("%d", &choice); switch(choice){ case 1: set_diff(); play(); break; case 2: exit(0); break; default: main_menu(); } } void play(){ sn.init(); init(); sn.add(); length = 2; char key; short int foodx, foody; //apple's coordinates short int moves = 29; while(true){ clear_screen(); print(); if(kbhit()) key = getch(); //If key is pressed switch(key){ case 'w': sn.up(); break; case 's': sn.down(); break; case 'a': sn.left(); break; case 'd': sn.right(); break; case '0': exit(0); break; } moves++; if(moves==30 || eaten){ //the apple changes its location if(!eaten) scr[foodx][foody] = ' '; else length++; moves = 0; foodx = rand()%H; foody = rand()%W; scr[foodx][foody] = 'o'; eaten = false; } Sleep(diff); } } void init(){ for(i = 0; i < H; i++) for(j = 0; j < W; j++) scr[j] = ' '; } void print(){ for(i = 0; i < H; i++){ for(j = 0; j < W; j++) printf("%c ", scr[j]); printf("\n"); } printf("Length: %d ", length); for(j = 5; j < W; j++) printf(" "); printf("+"); } void clear_screen (){ //Actually, this func does not clear, COORD coord = {0}; //it just set the cursor at the HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE ); // top left corner of the screen SetConsoleCursorPosition ( h, coord ); } void intro(){ clear_screen(); printf("\n\n\t\tSNAKE\n\n"); printf("\tControls: WASD\n\n"); getch(); } void game_over(){ clear_screen(); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\tGAME OVER!\n\n"); Sleep(1000); main_menu(); } void set_diff(){ printf("\n\tDifficulty (1-5): "); scanf("%d", &diff); diff = (5 - diff)*25; } Note: Because of the "clear" function it only works for Windows. MarrShal
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!