From: Dan Newsgroups: comp.os.msdos.djgpp Subject: Allegro and Asteroids Date: Sun, 01 Mar 1998 15:52:17 -0800 Organization: @Home Network Lines: 53 Message-ID: <34F9F4B1.6CE0@home.com> Reply-To: dyoon AT home DOT com NNTP-Posting-Host: cc104221-a.bnapk1.occa.home.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Ok, I'm having some problems trying to make my little asteroids clone game do the following...turn the ship in a certain direction, and if i press the up arrow key, have the ship move in the direction it's front end is pointing. I have some code written but it doesn't work properly. If anyone could tell me what I'm doing wrong I would really appreciate it. [begin loop] if(key[KEY_UP]) { float radian_angle = (angle*180)/PI; scale_x = cos(radian_angle); scale_y = sin(radian_angle); acc_x = scale_x*1; acc_y = scale_y*1; } vel_x += acc_x; vel_y += acc_y; if(vel_x > SHIP_MAX_SPEED) vel_x = SHIP_MAX_SPEED; if(vel_y > SHIP_MAX_SPEED) vel_y = SHIP_MAX_SPEED; if(vel_x < -SHIP_MAX_SPEED) vel_x = -SHIP_MAX_SPEED; if(vel_y < -SHIP_MAX_SPEED) vel_y = -SHIP_MAX_SPEED; pos_x += vel_x; pos_y += vel_y; [end loop] the ship starts off with the front of the ship pointing north, so the ship's "angle" variable starts off at 90. pressing the right arrow key will decrement the angle, and the left arrow key will increment it. i know that my code is a little bit off because on the monitor, going up the screen will actually mean decrementing the Y axis...but my main problem is that the angle isn't even right. for example, i start the ship off at 90 degrees...so if i just press the up arrow key from the start of the game, the ship should go up the screen? instead it goes at some weird angle. help will be much appreciated. Oh, and i'm sorry if this is the wrong place to ask this question...but i was thinking that maybe there are some djgpp specific math routines??? Daniel