RigidChips
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Tag

3 posters

Go down

Tag   Empty Tag

Post by DanielLC Fri Nov 26, 2010 6:25 pm

I don't know all the stuff with multiplayer, so I can't finish this. I'd be happy for anyone else to finish it for me.

Right now, it just creates a certain number of balls (currently set to four), and lets them tag each other.

There are many slight variations of tag, so the rules for this one:

  • If you are start out too close to it, or end up too close to it after someone's tagged, you can't be tagged until you get a certain distance away (currently eight meters).
  • Otherwise, if it gets within a certain distance of you (currently four meters), you're tagged, and you become it.
  • There is a red icosahedron around it, so you can tell who it is.


This is a scenario. Save it as a .rcs . I don't know how the games work.

Code:
function makeV(size)
  local i
  local vector={}
  for i=1,size do
    table.insert(vector,0)
  end
  return vector
end

function len3(x,y,z)
  return (math.sqrt(x^2+y^2+z^2))
end

function dist(player)
  return len3(_OX(player)-_OX(it),_OY(player)-_OY(it),_OZ(player)-_OZ(it))
end

function close()            --finds out who's close to it
  for i=0,PLAYERS-1 do
    if dist(i) <= CLOSEDIST then
      far[i+1]=false
    else
      far[i+1]=true
    end
  end
end

function tagBack()         --finds out if anyone just got far enough from it to get tagged back
  for i=0,PLAYERS-1 do
    if dist(i) > CLOSEDIST then
      far[i+1]=true
    end
  end
end

function tag()            --finds out if anybody is liable to be tagged, and tags them
  for i=0,PLAYERS-1 do
    if dist(i) <= TAGDIST then
      if far[i+1] then
        it=i
        close()
        return
      end
    end
  end
end

function face(x,y,z,dx,dy,dz)
  local phi=(1+math.sqrt(5))/2

  _MOVE3D(dx,y+dy,phi*z+dz)
  _LINE3D(x+dx,phi*y+dy,dz)
  _MOVE3D(x+dx,phi*y+dy,dz)
  _LINE3D(phi*x+dx,dy,z+dz)
  _MOVE3D(phi*x+dx,dy,z+dz)
  _LINE3D(dx,y+dy,phi*z+dz)
end

function crossHair(x,y,z,r,color)
  r=r/8*math.sqrt(10+2*math.sqrt(5))
  _SETCOLOR(color)
  face( r, r, r,x,y,z)
  face( r, r,-r,x,y,z)
  face( r,-r, r,x,y,z)
  face( r,-r,-r,x,y,z)
  face(-r, r, r,x,y,z)
  face(-r, r,-r,x,y,z)
  face(-r,-r, r,x,y,z)
  face(-r,-r,-r,x,y,z)
  local phi=(1+math.sqrt(5))/2
  _MOVE3D(x,y+r,z+r*phi)
  _LINE3D(x,y-r,z+r*phi)
  _MOVE3D(x,y+r,z-r*phi)
  _LINE3D(x,y-r,z-r*phi)
  _MOVE3D(x+r,y+r*phi,z)
  _LINE3D(x-r,y+r*phi,z)
  _MOVE3D(x+r,y-r*phi,z)
  _LINE3D(x-r,y-r*phi,z)
  _MOVE3D(x+r*phi,y,z+r)
  _LINE3D(x+r*phi,y,z-r)
  _MOVE3D(x-r*phi,y,z+r)
  _LINE3D(x-r*phi,y,z-r)
end

function showIt()
  crossHair(_OX(it),_OY(it),_OZ(it),2,16711680)
end

function OnFrame()
  tagBack()
  tag()
  out(0,"Player "..it.." is it.")
  out(1,_PLAYERS())
  showIt()
end

function OnInit()
  math.randomseed(_STICKS())
  TAGDIST = 4            --distance at which it can tag someone
  CLOSEDIST = 8            --distance you have to go from it before it's allowed to tag you
  PLAYERS = 4

  far=makeV(PLAYERS)         --tells if they're still to far to tag back
  it=math.random(PLAYERS)-1
  close()

   --this is temporary
  for i=0,PLAYERS-1 do
   x=math.random(50)-25
   z=math.random(50)-25
   _ADDBALL(1.0,x,_GETY(x,z)+3,z,0.01)
  end
end

function OnReset()
end

function OnMode()
end


Last edited by DanielLC on Sat Nov 27, 2010 10:38 am; edited 1 time in total

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

Back to top Go down

Tag   Empty Re: Tag

Post by JHaskly Fri Nov 26, 2010 7:23 pm

Unfortunately, balls don't appear on multiplayer.

You could do it with balls though.

JHaskly
Admin

Posts : 235
Join date : 2010-07-16
Age : 28
Location : Brisbane

Back to top Go down

Tag   Empty Re: Tag

Post by madbob2 Fri Nov 26, 2010 7:34 pm

What???

Maybe you could have a model that is like a ball, and then if it comes within 5 coordinates of another model then that model becomes it!
madbob2
madbob2
Tank
Tank

Posts : 87
Join date : 2010-07-16
Age : 27
Location : Orz Lake.x

Back to top Go down

Tag   Empty Re: Tag

Post by DanielLC Fri Nov 26, 2010 8:11 pm

It's not really supposed to use balls on multiplayer. I'd replace _OX() with _PLAYERX() etc.

Come to think of it, I think I just need to know how to find the number of players. I tried _PLAYERS(), which returned zero. That, and I'd like to be able to test it.

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

Back to top Go down

Tag   Empty Re: Tag

Post by JHaskly Sat Nov 27, 2010 4:47 am

_PLAYERS() returned zero? It should return more than that when you are connected.

JHaskly
Admin

Posts : 235
Join date : 2010-07-16
Age : 28
Location : Brisbane

Back to top Go down

Tag   Empty Re: Tag

Post by DanielLC Sat Nov 27, 2010 10:40 am

I wasn't using multiplayer. I've never actually done that before.

I tried it just now and it seems to work.

Do I need to make this accept new players coming in?

I just realized I added a bunch of C++ comments. I replaced them with lua comments, so it should work now.

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

Back to top Go down

Tag   Empty Re: Tag

Post by JHaskly Sat Nov 27, 2010 4:59 pm

It might make sense to make it acept new players. Another thing, make sure it can handle players quitting.

JHaskly
Admin

Posts : 235
Join date : 2010-07-16
Age : 28
Location : Brisbane

Back to top Go down

Tag   Empty Re: Tag

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum