Search Results

Search found 8 results on 1 pages for 'moaz'.

Page 1/1 | 1 

  • Knowing so much but application is a problem?

    - by Moaz ELdeen
    In my work, my friends always tell me, you know so much about computer science, electronics engineering,..etc. But I have difficulty in applying them and my code is crap. How to solve that problem? Will I be better or programming isn't my career? For example, yes I know OCTree that is used for space partitioning in games and it is used for optimization, did I implement it? No, but I know about it in principle.. Do I know algorithms like Sorting, Searching,..etc? Yes, and I know them pretty well, but didn't implement them.. When I get a task, I struggle in applying the things that I know...

    Read the article

  • Safe zone implementation in Asteroids

    - by Moaz
    I would like to implement a safe zone for asteroids so that when the ship gets destroyed, it shouldn't be there unless it is safe from other asteroids. I tried to check the distance between each asteroid and the ship, and if it is above threshold, it sets a flag to the ship that's a safe zone, but sometimes it work and sometimes it doesn't. What am I doing wrong? Here's my code: for (list<Asteroid>::iterator itr_astroid = asteroids.begin(); itr_astroid!=asteroids.end(); ) { if(currentShip.m_state == Ship::Ship_Dead) { float distance = itr_astroid->getCenter().distance(Vec2f(getWindowWidth()/2,getWindowHeight()/2)); if( distance>200) { currentShip.m_saveField = true; break; } else { currentShip.m_saveField = false; itr_astroid++; } } else { itr_astroid++; } } At ship's death: if(m_state == Ship_Dead && m_saveField==true) { --m_lifeSpan; } if(m_lifeSpan<=0 && m_saveField == true) { m_state = Ship_Alive; m_Vel = Vec2f(0,0); m_Pos.x = app::getWindowWidth()/2; m_Pos.y = app::getWindowHeight()/2; m_lifeSpan = 100; }

    Read the article

  • Recommendation for Improving Programming Skills

    - by Moaz ELdeen
    I'm 25, I know C++ syntax since 9 years.. but It seems that I have copied so much code, and I didn't learn that much and didn't solve a lot of algorithms in my own. Currently I'm working for computer vision programmer as a junior and I have difficulity of doing algorithms like blob tracking or object tracking, writing algorithms like KNN, Quadtree,..etc. I don't know what to do, or what to improve, I tried to write asteriods game, I have finished it, and here you can watch it https://www.youtube.com/watch?v=jw0L4aCB4TU What should I do more to enhance my skills ?

    Read the article

  • Explaining Asteroids Movement code

    - by Moaz ELdeen
    I'm writing an Asteroids Atari clone, and I want to figure out how the AI for the asteroids is done. I have came across that piece of code, but I can't get what it does 100% if ((float)rand()/(float)RAND_MAX < 0.5) { m_Pos.x = -app::getWindowWidth() / 2; if ((float)rand()/(float)RAND_MAX < 0.5) m_Pos.x = app::getWindowWidth() / 2; m_Pos.y = (int) ((float)rand()/(float)RAND_MAX * app::getWindowWidth()); } else { m_Pos.x = (int) ((float)rand()/(float)RAND_MAX * app::getWindowWidth()); m_Pos.y = -app::getWindowHeight() / 2; if (rand() < 0.5) m_Pos.y = app::getWindowHeight() / 2; } m_Vel.x = (float)rand()/(float)RAND_MAX * 2; if ((float)rand()/(float)RAND_MAX < 0.5) { m_Vel.x = -m_Vel.x; } m_Vel.y =(float)rand()/(float)RAND_MAX * 2; if ((float)rand()/(float)RAND_MAX < 0.5) m_Vel.y = -m_Vel.y;

    Read the article

  • Save Zone Implementation in Asteroids

    - by Moaz
    I would like to implement a safe zone for asteroids so that when the ship gets destroyed, it shouldn't be there unless it is safe from other asteroids. I tried to check the distance between each asteroid and the ship, and if it is above threshold, it sets a flag to the ship that's a safe zone, but sometimes it work and sometimes it doesn't for (list<Asteroid>::iterator itr_astroid = asteroids.begin(); itr_astroid!=asteroids.end(); ) { if(currentShip.m_state == Ship::Ship_Dead) { float distance = itr_astroid->getCenter().distance(Vec2f(getWindowWidth()/2,getWindowHeight()/2)); if( distance>200) { currentShip.m_saveField = true; break; } else { currentShip.m_saveField = false; itr_astroid++; } } else { itr_astroid++; } }

    Read the article

  • Getting Center and Radius of Irregural Object

    - by Moaz ELdeen
    I have drawn an asteroid object manually , and would like to get its center/radius by a specific equation. I think I can get them by calculated and hard-coded values. The code to draw the asteroid: void Asteroid::Draw() { float ratio = app::getWindowWidth()/app::getWindowHeight(); gl::pushMatrices(); gl::translate(m_Pos*ratio); gl::scale(3.5*ratio,3.5*ratio,3.5*ratio); gl::color(ci::Color(1,1,1)); gl::drawLine(Vec2f(-15,0),Vec2f(-10,-5)); gl::drawLine(Vec2f(-10,-5),Vec2f(-5,-5)); gl::drawLine(Vec2f(-5,-5),Vec2f(-5,-8)); gl::drawLine(Vec2f(-5,-8),Vec2f(5,-8)); gl::drawLine(Vec2f(5,-8),Vec2f(5,-5)); gl::drawLine(Vec2f(5,-5),Vec2f(10,-5)); gl::drawLine(Vec2f(10,-5),Vec2f(15,0)); gl::drawLine(Vec2f(15,0),Vec2f(10,5)); gl::drawLine(Vec2f(10,5),Vec2f(-10,5)); gl::drawLine(Vec2f(-10,5),Vec2f(-10,5)); gl::drawLine(Vec2f(-15,0),Vec2f(-10,5)); gl::popMatrices(); } According to the answer I have written that code to calculate the radius, is it correct or not ? cinder::Vec2f Asteroid::getCenter() { return ci::Vec2f(m_Pos.x, m_Pos.y); } double Asteroid::getRadius() { ci::Vec2f _vec = (getCenter()- Vec2f(15,5)); return _vec.length()*0.3f; }

    Read the article

  • Checking collision of bullets and Asteroids

    - by Moaz ELdeen
    I'm trying to detect collision between two list of bullets and asteroids. The code works fine, but when the bullet intersects with an asteroid, and that bullet passes through another asteroid, the code gives an assertion, and it says about it can't increment the iterator. I'm sure there is a small bug in that code, but I can't find it. for (list<Bullet>::iterator itr_bullet = ship.m_Bullets.begin(); itr_bullet!=ship.m_Bullets.end();) { for (list<Asteroid>::iterator itr_astroid = asteroids.begin(); itr_astroid!=asteroids.end(); itr_astroid++) { if(checkCollision(itr_bullet->getCenter(),itr_astroid->getCenter(), itr_bullet->getRadius(), itr_astroid->getRadius())) { itr_astroid = asteroids.erase(itr_astroid); } } itr_bullet++; }

    Read the article

  • setting the position in different resolution

    - by Moaz
    I have a normal game window which is 640*480, and everything is fine, but when I try to maximize the window, the objects translate to different positions on the screen, for example If I have a circle which is drawn at the center in the normal window, when I try to maximize it, it shifts away from the center of the screen. How do I adjust it so it draws at the center in both normal window and maximized window ?

    Read the article

1