This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Gumball's profile picture

Game Help [Solved nvm disregard m80]

Started by Gumball, 15 March 2016 - 04:40 AM
Gumball #1
Posted 15 March 2016 - 05:40 AM
I recently made a post called SimpleCCRockets, it's a game where you build and fly spaceships.
My problem is, when you build the rocket, it builds the rocket from the very top, going down, which is good, but when you fly, I want the spaceship you built on the bottom of the screen. And for the love of me I cannot get an algorithm that does it correctly. For now i'm stuck with the spaceship being at the top.

Pastebin: FG2KZuRf
Go to the drawRocket() function. That's where the problem is. At the Y part of the paintutils.drawImage is what needs to be tweaked.

Current function code:

local function drawRocket()
  nextPos = 1
  totalHeight = 0
  for i=1,#rocketDesign do
	totalHeight = totalHeight + #rocketDesign
  end
  for i=1,#rocketDesign do
	if(rocketDesign[i] == engineOff or rocketDesign[i] == engineOn) then
	  paintutils.drawImage(rocketDesign[i],w/2-1,nextPos)
	else
	  paintutils.drawImage(rocketDesign[i],w/2,nextPos)
	end
  end
end


//Off topic
I'm gonna bet that Bomb Bloke is going to respond first.
Nope,
Edited on 15 March 2016 - 05:50 AM
Dog #2
Posted 15 March 2016 - 06:02 AM
The way I'd do it would be to use your h variable (the terminal height), then set nextPos to h minus the height of the rocket, like so…

local function drawRocket()
  nextPos = h - #rocketDesign
  ...
end
Gumball #3
Posted 15 March 2016 - 06:32 AM
The way I'd do it would be to use your h variable (the terminal height), then set nextPos to h minus the height of the rocket, like so…

local function drawRocket()
  nextPos = h - #rocketDesign
  ...
end

Nope, sorry, that didn't work.
I just got it to work, using your method (kinda)
I ADDED h-#rocketDesign to the nextPos thingy when drawing each part. :P/>
Edited on 15 March 2016 - 05:49 AM