Randomly generated platform program
Author |
Message |
IshiggyDiggy

|
Posted: Mon Dec 17, 2012 9:53 am Post subject: Randomly generated platform program |
|
|
What is it you are trying to achieve?
A randomly generated platform for our pacman program. I'm trying to make it so pacman can jump on platforms/lines that are randomly generated.
What is the problem you are having?
I don't know how to code the program to make it.
Describe what you have tried to solve this problem
I tried to make an elsif statement.
Turing: |
var Pacman : int := Pic.FileNew ("Untitled-2.bmp")
var chars : array char of boolean
var x1 : int := 1
var x2 : int := x1 + 10
var y1 : int := 1
var y2 : int := y1 + 10
var xv : real := 0
var yv : real := 0
var g : real := 1
var ground : boolean := true
setscreen ("graphics:540;600,offscreenonly,nobuttonbar,title:Player Movement Tutorial")
loop
Input.KeyDown (chars )
if chars ('w') and y2 < maxy and ground = true then
yv + = 8
end if
if chars ('a') and x1 > 0 then
xv - = 1
elsif chars ('d') and x2 < maxx then
xv + = 1
elsif chars (KEY_ESC) then
exit
end if
if y1 > 0 then
yv - = g
elsif y1 < 0 then
yv := 0
y1 := 0
end if
if xv > 0 then
xv - = 0. 5
elsif xv < 0 then
xv + = 0. 5
end if
if x1 < 0 then
x1 := 0
xv := 0
elsif x2 > maxx then
x1 := maxx - 10
xv := 0
end if
if y2 > maxy then
y1 := maxy - 10
yv := 0
end if
if y1 = 0 then
ground := true
else
ground := false
end if
x1 + = round (xv )
y1 + = round (yv )
x2 := x1 + 10
y2 := y1 + 10
Pic.Draw (Pacman,x1, y1, 0)
locate (1, 1)
View.Update
delay (10)
cls
end loop
|
Please specify what version of Turing you are using
4.1 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Panphobia

|
Posted: Mon Dec 17, 2012 10:43 am Post subject: RE:Randomly generated platform program |
|
|
in essence you are asking us to do the program for you? |
|
|
|
|
 |
Insectoid

|
Posted: Mon Dec 17, 2012 11:38 am Post subject: RE:Randomly generated platform program |
|
|
You need to store your platforms in an array, and then loop over them to check for collisions. If you don't know how to check for collisions, check the Turing Walkthrough. |
|
|
|
|
 |
|
|