platformer problem
Author |
Message |
slender0123
|
Posted: Fri Sep 06, 2013 9:40 am Post subject: platformer problem |
|
|
What is it you are trying to achieve?
make my text from a .txt appear on screen as the platforms
What is the problem you are having?
not appearing
Turing: |
const Gravity := 2
var x, y := 100
var y_velocity := 0
var keys : array char of boolean
var tiles : array 0.. 35, 0.. 35 of int
setscreen ("offscreenonly,graphics:500;500")
var cheese : char
var FileName : string := "textmap1.txt"
var FileNo : int
open : FileNo, FileName, get
for decreasing y2 : 35 .. 0
for x2 : 0.. 35
get : FileNo, cheese
tiles (x2, y2 ) := ord (cheese )
end for
end for
close (FileNo )
for x2 : 0 .. 35
for y2 : 0 .. 35
if tiles (x2, y2 ) = 1 then
Draw.FillBox (x2* 10, y2* 10, x2 * 10 + 10, y2 * 10 + 10, red)
end if
end for
end for
loop
Input.KeyDown (keys )
if keys (KEY_UP_ARROW) and y <= 0 then
y_velocity := 30
end if
if keys (KEY_LEFT_ARROW) and x > 0 then
x - = 5
end if
if keys (KEY_RIGHT_ARROW) and x < maxx then
x+ = 5
end if
y_velocity - = Gravity
y + = y_velocity
if y < 0 then
y := 0
y_velocity := 0
end if
Draw.FillOval(x,y, 15, 15, blue)
View.Update
delay (20)
cls
end loop
|
Please specify what version of Turing you are using
4.1 im pretty sure |
|
|
|
|
|
Sponsor Sponsor
|
|
|
evildaddy911
|
Posted: Fri Sep 06, 2013 11:29 am Post subject: RE:platformer problem |
|
|
where do you actually draw the text from the file? |
|
|
|
|
|
slender0123
|
Posted: Fri Sep 06, 2013 7:20 pm Post subject: RE:platformer problem |
|
|
too be brutily honist, I really dont know lmao, im 100% new to this, I thought a little to big for my first thing to make, but, I gotta learn somehow lol.
I'm pretty sure I'm getting the text from the file, i just need to get it drawn. |
|
|
|
|
|
Raknarg
|
Posted: Fri Sep 06, 2013 7:52 pm Post subject: RE:platformer problem |
|
|
What is your screen but a 2D array of pixels? It's no different than your 35x35 array of text.
Split your screen into 35x35 segments, and draw each platform in the corresponding slot. |
|
|
|
|
|
slender0123
|
Posted: Fri Sep 06, 2013 8:08 pm Post subject: RE:platformer problem |
|
|
That would take a lot of coding though, would it not? |
|
|
|
|
|
Nathan4102
|
Posted: Fri Sep 06, 2013 8:50 pm Post subject: RE:platformer problem |
|
|
Not at all! Look into case statements, if you haven't already, and you should be able to paint the map in a decent amount of lines. Post your code here if you want and we can tell you how it is.
Something like this:
case (character in your .txt) of:
a: draw ...;
b: draw ...;
c: draw ...;
end case
Or, if youre using pictures rather than single pixels/characters, you could name your files exactly what they'd be in the .txt + the bmp, and then use this:
for ...
drawpic(text(i) + ".bmp", ...)
end for
Sorry for the lazy coding/examples, I'm just getting off to bed now, and I don't feel like doing this all properly, but you should get the idea and be able to come up with the code yourself.
Good luck! |
|
|
|
|
|
Raknarg
|
Posted: Sat Sep 07, 2013 9:20 am Post subject: RE:platformer problem |
|
|
Turing: |
for i : 1 .. 35
for j : 1 .. 35
pic (i, j ) = Pic.FIleNew (strint (tiles (i, j )) + ".jpg")
end for
end for
for i : 1 .. 35
for j : 1 .. 35
Pic.Draw (i * picWidth, j * picHeight, picCopy, pic (i, j )
end for
end for
|
If you have tile pictures named the same as the numbers in the text file, it should be fine. Or if you dont want to use pictures, just take the second part of my example and replace it with Draw.FIllBox or something |
|
|
|
|
|
|
|