A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: [beta] LilRacerz (workign title)

  1. #1
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149

    [beta] LilRacerz (workign title)

    Ive finally got my little rally game ready for the bigtime, it just needs some bug bashing love from my fellow fk'ers.

    If you have a few moments spare to play a fun little racing game... any bugs found greatly appreciated. Note, the score submission isnt connected yet.

    This is a testing URL only.


    http://blastone.com/games/lilracerz/

    Its my first game built using flex as the editor... I must say I am a convert

    many thanks
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

  2. #2
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    edit
    haha. i'm a dummy. no prize money on the first race.

    the night race is cool but the contrast is really hard on the eyes

    smoke is rendered above the trees

    i'd put some of those little rocks on the track. they are fun to smash into
    Last edited by tonypa; 10-20-2008 at 03:18 AM.
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  3. #3
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149
    hey blink, good feedback. Thanks.
    I have the dust coming through the trees as the dust is on its own layer, so it needs to be above all the ground based objects (eg rocks) yeah it does go about the trees but I call that artistic license

    I might put a couple of rocks mid track just for you

    Thanks for looking.
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

  4. #4
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    nice work. Plays very nicely, and the AI can get themselves back on track and kick my arse

    I like
    lather yourself up with soap - soap arcade

  5. #5
    Senior Member Sietjp's Avatar
    Join Date
    Jan 2005
    Location
    Paris, France
    Posts
    711
    Very good!
    You forgot the "Wrong way!" warning
    Could you tell more about the AI ? I'm trying also to make a racing game and I've been stuck since 3 days on the AI.

  6. #6
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149
    hey sietjp,

    here is my AI class, see if anything in there is useful, I dont mind posting this one in isolation, just dont be asking for the vehicle and vehicle manager classes as well as they are my secrets

    Code:
    package game.vehicle {
    	
    	import flash.display.*;
    	import flash.events.*;
    	import flash.geom.*;
    	import flash.text.*;
    	import flash.utils.*;
    	
    	import game.track.*;
    	
    	import geom.Line;
    	
    	public class Controller extends EventDispatcher {
    		
    		public static var COMPLETED:String = "aiCompletedRace"		
    		
    		private var m_isCompleted:Boolean = false
    		private var m_isStuck:Boolean = false // set from collision manager if car gets stuck, lets it reverse
    		
    		private var m_lap:int = 0
    		
    		private var m_tolerance:Number = 200
    		private var m_waypointLength:Number = 160
    		private var m_toleranceAngle:Number = 0.2		
    
    		private var m_totalTime:int = 0
    		private var m_lapTimes:Array = []
    		
    		private var m_ptWaypoint:Point
    		private var m_ptWaypointNext:Point
    		private var m_ptVehicle:Point
    		private var m_hasFinished:Boolean = false
    		
    		private var m_track:Track
    		private var m_vehicle:Vehicle
    		private var m_waypointCurrent:int = 0	
    		private var m_waypointsLength:int
    		private var m_setCompleteTime:int = 1500
    		private var m_line:Line
    		private var m_waypoints:Array = []
    		private var m_container:Sprite
    		private var m_pathPoint:Number // poisition on waypoint line to aim for 0 is bottom, 0.5 is middle, 1 is top, gives variety of paths
    		private var m_unstickTime:Number = 500 // ms of reversing if stuck in a collision
    		
    		
    		private var ax, ay, acc, dvx, dvy, dsx, dsy, dangle:Number // extrapolated car
    		private var vvx1, vvx2, vvy1, vvy2:Number
    		private var m_radius:Number	
    		private var m_steps:int = 1	
    		private var m_circlePos:Point
    		private var m_distance:Number
    		private var m_originx, m_originy:Number
    		private var m_steeringHardness:int = 1 // turn hard in tight corners
    		
    		public function Controller(a_track:Track, a_vehicle:Vehicle, a_container:Sprite, a_pathPoint:Number) 
    		{
    			m_track = a_track
    			m_vehicle = a_vehicle
    			m_container = a_container
    			
    			m_pathPoint = a_pathPoint
    			
    			// build m_waypoints
    			for (var i = 0; i < m_track.waypointArray.length; i++)
    			{
    				m_line = Line.createLine(m_track.waypointArray[i][0], m_track.waypointArray[i][1], m_waypointLength, m_track.waypointArray[i][2] * Constants.DEG2RAD)
    				m_waypoints.push(m_line)
    				
    				//Line.draw(m_line, a_container)
    			}
    			
    			m_ptWaypoint = Line.getPoint(m_waypoints[m_waypointCurrent], m_pathPoint )	
    			
    			//Line.drawPoint(m_ptWaypoint, m_container)
    			//Line.draw(new Line(m_ptWaypoint, new Point(m_vehicle.x, m_vehicle.y)), m_container)
    			
    		}
    		
    		public function get waypoint():int
    		{
    			return m_waypointCurrent
    		}
    		
    		public function get lap():int
    		{
    			return m_lap
    		}
    		
    		public function get isStuck():Boolean
    		{
    			return m_isStuck
    		}
    		
    		public function set isStuck(val:Boolean)
    		{
    			m_isStuck = val
    		}
    		
    		private function unStick():void
    		{
    			m_isStuck = false
    		}
    		
    		public function render(_time:int):void
    		{
    			if (m_isStuck)
    			{
    				// stuck in a collision so reverse
    				m_vehicle.acceleration = -1;
    				setTimeout(unStick, m_unstickTime)
    			}
    			else
    			{
    				// Simple Waypoint Ai
    			
    				m_ptVehicle = new Point(m_vehicle.x,m_vehicle.y)
    			
    				// check m_distance to next m_waypoint
    				if (Point.distance(m_ptWaypoint, m_ptVehicle) < m_tolerance) 
    				//if (Line.intersects(m_waypoints[m_waypointCurrent], m_vehicle.line))
    				{
    					//if (Math.random() > 0.9) m_waypointCurrent++ // skip occasionally
    					m_waypointCurrent++
    					
    					if (m_waypointCurrent >= m_track.waypointArray.length) 
    					{
    						m_waypointCurrent = 0
    						m_lap++
    						
    						m_lapTimes.push(_time - m_totalTime)
    						m_totalTime += _time
    						
    						if (m_lap >= m_track.laps) // need to cross the finish line 
    						{
    							m_hasFinished = true
    						}
    					}
    					
    					//m_pathPoint = 0.3 + Math.random() * 0.3 // track variation among middle 1/3 of line
    					
    					m_ptWaypoint = Line.getPoint(m_waypoints[m_waypointCurrent], m_pathPoint )	
    					
    					//Line.drawPoint(m_ptWaypoint, m_container)
    				
    					if (m_hasFinished && m_waypointCurrent >= 0)
    					{
    						// makes sure we run over the 0 m_waypoint ie the start / finish
    						trace("AI PLAYER COMPLETED RACE")
    						dispatchEvent(new Event(COMPLETED))
    						
    						// add a delay here to let them all get over the finish line.
    						setTimeout(setIsComplete, m_setCompleteTime)
    					}
    				}
    				
    				// get shortest angle to m_waypoint and turn towards it
    				var relativeAngle:Number = findAngle(m_ptVehicle, m_ptWaypoint)
    					
    				if (distToAngle(relativeAngle, m_vehicle.angle) > m_toleranceAngle) 
    				{
    					m_vehicle.steering = -0.5 * m_steeringHardness;		
    				}
    				else if (distToAngle(relativeAngle, m_vehicle.angle) < -m_toleranceAngle) 
    				{
    					m_vehicle.steering = 0.5 * m_steeringHardness;
    				}
    				else
    				{
    					m_vehicle.steering = 0;
    				}
    				
    				if (!m_isCompleted)
    				{
    					
    					/* Predictive speed 
    					*/
    					
    					dvx = m_vehicle.vx
    					dvy = m_vehicle.vy
    					dsx = m_vehicle.x
    					dsy = m_vehicle.y
    					dangle = m_vehicle.angle
    									
    					
    					// look a number of m_steps intot he future to give us values for velocity and acceleration
    					for (var i=0; i<m_steps; i++)
    					{
    						if (m_vehicle.steering < 0) dangle -= m_vehicle.STEERING_ANGLE_INC
    						else dangle += m_vehicle.STEERING_ANGLE_INC
    						dsx += m_vehicle.speed * Math.sin(dangle)
    						dsy += m_vehicle.speed * Math.cos(dangle)				
    					}
    						
    					vvy1 = Math.cos(m_vehicle.angle) * m_vehicle.speed
    					vvx1 = Math.sin(m_vehicle.angle) * m_vehicle.speed
    					vvx2 = Math.sin(dangle) * m_vehicle.speed
    					vvy2 = Math.cos(dangle) * m_vehicle.speed
    					
    					ax = (vvx2 - vvx1) / m_steps
    					ay = (vvy2 - vvy1) / m_steps
    					acc = Math.sqrt(ax * ax + ay * ay)
    					
    					if (m_vehicle.speed > 0) m_radius = (m_vehicle.speed * m_vehicle.speed) / acc
    					else m_radius = 2
    								
    					// get center of turn circle
    					if (m_vehicle.steering < 0)
    					{
    						m_originx = m_vehicle.x + m_radius * Math.sin(m_vehicle.angle)
    						m_originy = m_vehicle.y - m_radius * Math.cos(m_vehicle.angle)
    					}
    					else
    					{
    						m_originx = m_vehicle.x - m_radius * Math.sin(m_vehicle.angle )
    						m_originy = m_vehicle.y + m_radius * Math.cos(m_vehicle.angle)
    					}
    						
    					//m_container.graphics.lineStyle(1, 0xff0000);
    					//m_container.graphics.drawCircle(m_originx, m_originy, m_radius);
    					
    					// see if next node is in range of the speed velocity circle. If it is we slow down, if it isnt we speed up	
    					m_circlePos = new Point(m_originx, m_originy)								
    					m_distance = m_circlePos.subtract(m_ptWaypoint).length
    					
    					if (m_distance < m_radius)
    					{
    						// Decelerate or turn tight
    						m_vehicle.acceleration = 1;
    						m_steeringHardness = 2 
    					}
    								
    					else
    					{
    						// Accelerate
    						m_vehicle.acceleration = 1;
    						m_steeringHardness =1 // smoother turning
    					}
    				}
    				else 
    				{
    					m_vehicle.acceleration = 0 // level finished, slow down to a stop
    				}
    			}
    		}
    		
    		private function setIsComplete():void
    		{
    			// dirty hack to let the cars cross the finish line, start to slow them past the finish line
    			m_isCompleted = true
    		}
    		
    		private function findAngle(p0:Point, p1:Point):Number
    		{
    			var dx = p1.x-p0.x
    			var dy = p1.y-p0.y
    			return Math.atan2(dy,dx)
    		}
    		
    		private function checkAngle(dir:Number):Number	
       		{
            	if (dir > Math.PI) dir = dir - 2 * Math.PI
    			if (dir < -Math.PI) dir = dir + 2 * Math.PI
    			return dir
    		}
    		
    		public function distToAngle(ang:Number, targ:Number)
    		{
    			ang *= 180 / Math.PI
    			targ *= 180 / Math.PI
    			
    			ang %= 360;
    			targ %= 360;
    			
    			if(targ < 0) targ += 360;
    			
    			var diff = targ - ang;
    			
    			if(diff > 180) diff -= 360;
    			else if(diff<-180) diff+=360;
    			
    			diff *= Math.PI / 180
    			return diff;
    		}
    		
    		public function distToAngle2(ang:Number, targ:Number):Number
    		{
    			return Math.atan2(Math.sin(targ-ang),Math.cos(targ-ang));
    		}
    	}
    }
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

  7. #7
    Senior Member Sietjp's Avatar
    Join Date
    Jan 2005
    Location
    Paris, France
    Posts
    711
    Thx I appreciate.
    So you are using way points. I was afraid that the cars collide each others if they all use the same way points but it seems they don't.

  8. #8
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149
    I have my waypoints as a line, and each car gets a point on the line based on its starting position on the grid, so a car at the top forexample will always aim for the top part of the waypoint line. Thats what the m_pathpoint value is, a position (0 start, 1 end) along the line that is the waypoint
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

  9. #9
    Junior Member
    Join Date
    Oct 2008
    Posts
    14
    Maybe I just suck, but I think it's too hard. Try making the first few tracks with easier AI opponents, if you can. The first "tutorial" level is way to hard for a tutorial. The second level should be easier too. Then again, I might just suck. =P

  10. #10
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149
    zomguy... you just suck
    ive made the game so that you can just win with skill on each track... so its a matter of practise makes perfect
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

  11. #11
    formerly hooligan2001 :) .hooligan's Avatar
    Join Date
    Mar 2008
    Posts
    405
    Great game Mr Flashkit. Can't really think of anything I didn't like. The steering is much better then your previous version too and the overall GUI is pretty sexy too. Great work mate.

  12. #12
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    Is this the one with more than 200 classes?

  13. #13
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149
    i got it down to about 50 200 was maybe a slight exaggeration shhh
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

  14. #14
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    Looks amazing. Frame rate is too low to enjoy. Sorry!
    (Oh wait, I will try it in IE now)

  15. #15
    President PhobiK's Avatar
    Join Date
    Jan 2005
    Location
    Guatemala
    Posts
    918
    Great game! Very good looking and good gameplay too. I liked that there were different daytimes and that the weather changed; that made it quite interesting. It was a smooth game overall. I think the opponents behaviour can be improved though. I felt the game too easy because the other cars crashed from the beginning, and they were not racing next to me but I saw them every now and then passing round there crashing in the rocks and other obstacles. Maybe they don't reduce the speed (not shure though), and they should in the curves. Just my opinion. Other than that, sweet game
    This is MC. His _parents sent him to stop() by the super market to buy some _root beer if he wanted to gotoAndPlay() with his friends at the park later.

    This is my Blog!... The gaming Process
    Please check out my site: Giddel Creations

  16. #16
    Junior Member
    Join Date
    May 2007
    Location
    Denmark
    Posts
    18
    Where were you when I was a kid? I've spent a small fortune in quarters on this kind of game at the arcades :P

    This is the first flash game that I've restarted after failing miserably on my first try, one of the best I've played to date. I think I actually went "Oooh" when the car select popped up, those cars look really nice.

    My two cents:
    - Money: Once you've bought a car you might want to remove the pricetag from the car select screen, it looks like you have to pay for it again each time you want to race in it.

    - Night track: This is really nicely done, but damn was it confusing when the AI cars were around and light-cones were weaving everywhere. While it cuts down on realism, you could consider only having lights on the players car to lessen the confusion. Also on the night track all four of the AI cars crashed on the very first turn letting me have an easy lead. They caught up though.

  17. #17
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149
    het peanutR.
    I originally had it so it showed which car you had purchased, but I changed it so that after the race the car money is refunded to you so yes you do actually need to buy the car each time. This means you can 'sell' the car to race more expensive tracks if you wish too....
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

  18. #18
    Junior Member
    Join Date
    May 2007
    Location
    Denmark
    Posts
    18
    Ah, well then I guess it works exactly like it appears too - it was just me not noticing the refund. I like that you give a full refund instead of having to sell back cars at a reduced price

    I'll give it another play once I get home from work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center