How can I spawn randomly between two points?

I have a function which spawns a new platform every 1.8 seconds. I want the platform to spawn on a random y value. However I don’t know how to switch randomly between JUST two points (not 600 to 700, but 600 and 700).

Anybody know how to do this?

Here’s the code:

[code]
local function spawnPlatform()
local shortplatform = display.newImage( “DesertPlat1.png” )
shortplatform:setReferencePoint(display.BottomLeftReferencePoint);
shortplatform.x = 960
shortplatform.y = math.random (640 900)
physics.addBody( shortplatform, Platform )
shortplatform.bodyType = “kinematic”
shortplatform:setLinearVelocity( -450, 0 )
end

timer.performWithDelay( 1800, spawnPlatform, 0 ) [import]uid: 16789 topic_id: 6469 reply_id: 306469[/import]

Could you just have a random range of 1 to 2 then “interpret” the value?.

You could use a table if you wanted something more elaborate:

values[1] = 600
values[2] = 700

etc. [import]uid: 8353 topic_id: 6469 reply_id: 22340[/import]

Sorry I don’t really understand what you’re suggesting. (i’m new) [import]uid: 16789 topic_id: 6469 reply_id: 22341[/import]

The point is you only have 2 random values to choose from so you should only be generating a random number that can have 2 values.

pseudo code: (without using a table for simplicity)

choice = random(1, 2)

if choice = 1 then
y = 600
else
y = 700
end
[import]uid: 8353 topic_id: 6469 reply_id: 22343[/import]

O okay, I tried it out and it didnt work thought. I probably did something wrong. [import]uid: 16789 topic_id: 6469 reply_id: 22349[/import]

I have the same problem. I have an object shooting up from the bottom of the screen and would like it to shoot some bullets in random positions or time but I am not able to solve it. Any ideas? [import]uid: 22737 topic_id: 6469 reply_id: 22395[/import]

how about…

platform.y = math.random(6,7)\*100; [import]uid: 24493 topic_id: 6469 reply_id: 22439[/import]