Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Final Project for gr 11 Computer Science... side scroller problem
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Monduman11




PostPosted: Fri May 14, 2010 6:00 pm   Post subject: Final Project for gr 11 Computer Science... side scroller problem

What is it you are trying to achieve?
make my screen scroll sideways when i reach the end. the actual program is game2.t the rest are just things that either go with it or i use to try new things out


What is the problem you are having?
dont know where to start


Describe what you have tried to solve this problem
looked at tutorials, and also at the help section but i cant seem to find anything about a side scroller


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
4.1.1



Game.rar
 Description:
Everything is in the file, game2. t is the actual game the rest are either for the game or codes that i tried seperately then used in the game. if anyone could also help with the shield it would be greatly appreciated.

Download
 Filename:  Game.rar
 Filesize:  72.25 KB
 Downloaded:  120 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Fri May 14, 2010 6:32 pm   Post subject: RE:Final Project for gr 11 Computer Science... side scroller problem

So you couldn't find this in the help section from ~5 months ago?

You could also start with a look at the Wikipedia page.

Next, write down on paper exactly what you want the side-scroller to do. Will it follow your character exactly, proceed through the level at a given pace which the player must keep up with, or what? The simplest version is to centre the view around the player.

Work from that towards making an implementation.
Monduman11




PostPosted: Fri May 14, 2010 6:40 pm   Post subject: Re: Final Project for gr 11 Computer Science... side scroller problem

all i basically wanted to do is have it centered around the player so wherever he goes it follows i guess. like if he goes decides to go backwards then it should show the stuff previous.. do you get what im trying to say? or should i rephrase it?
Tony




PostPosted: Fri May 14, 2010 6:42 pm   Post subject: RE:Final Project for gr 11 Computer Science... side scroller problem

Well that does sound like you know where to start. Can you put together a little demo to test out the concept? (player staying center, and background moving left/right)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Monduman11




PostPosted: Fri May 14, 2010 6:44 pm   Post subject: Re: Final Project for gr 11 Computer Science... side scroller problem

ill try my best, but it might not come anywhere close lol
Tony




PostPosted: Fri May 14, 2010 6:48 pm   Post subject: RE:Final Project for gr 11 Computer Science... side scroller problem

Just use simple boxes to represent the character and the background objects.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Monduman11




PostPosted: Fri May 14, 2010 7:02 pm   Post subject: Re: Final Project for gr 11 Computer Science... side scroller problem

setscreen("offscreenonly,graphics:450;450")
var x, y : int
var click : int := 1
var pic : int := Pic.FileNew("guy.bmp")
var map : int := Pic.FileNew("map.bmp")
var z : int := 0
loop
View.Update
cls
mousewhere (x, y, click)
Pic.Draw(map,z,0,picMerge)
Pic.Draw(pic,x-17,y-9,picMerge)
if x = maxx div 2 - 10 then
z += 10
end if
end loop



Scroll.rar
 Description:
here is what i have so far if you would like to test it

Download
 Filename:  Scroll.rar
 Filesize:  9.36 KB
 Downloaded:  97 Time(s)

Tony




PostPosted: Fri May 14, 2010 7:25 pm   Post subject: RE:Final Project for gr 11 Computer Science... side scroller problem

Wait, do you want the background to move only when the character is at the edge? That works in things like RPGs when you switch rooms, not so much in a platformer game (maybe).

It'd be much easier if the character is always in the center (& jumps up/down), while the background always scrolls.

Think of it this way -- when you press RIGHT, if the character stays in the same spot and the background moves LEFT, then that works.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Monduman11




PostPosted: Fri May 14, 2010 7:29 pm   Post subject: Re: Final Project for gr 11 Computer Science... side scroller problem

true that could work to but what happens when i want to reach the edge? does the screen keep on trying to move or does it just stay there when its the end of the map?
so what ur saying is when i press Right instead of my character moving 3 spaces to the right the screen moves towards the left? right?
oh i see what ur saying Smile) i tried it out and it works kinda lol
Monduman11




PostPosted: Fri May 14, 2010 8:00 pm   Post subject: Re: Final Project for gr 11 Computer Science... side scroller problem

well i kinda got it to work but its a bit glitchy lol here is the code if you could please check it and hint some places where i could modify it a bit


var win := Window.Open ("graphics:640;480,offscreenonly")
setscreen ("graphics:450;450,nobuttonbar,position:center;center,offscreenonly")
colorback (white)
color (black)
View.Update
%Map
var map : array 1 .. 2 of int
map (1) := Pic.FileNew ("level1.bmp")
map (2) := Pic.FileNew ("level2.bmp")
var z : int := 0
%Character
var sprite : int
var pic, pic1 : int
var chars : array char of boolean

pic := Pic.FileNew ("guy.bmp")
pic1 := Pic.Mirror (pic)
sprite := pic

%positions
var posx, posy : int
var velx, vely : int
posx := 50
posy := 50
velx := 0
vely := 0

%hp
var HP : int
var HL : int
HP := 100
HL := 100

var damage : int := 1

var gravity : int := 1
var jump_speed : int := 60

%Timer
proc Timer


var timeRunning : int
timeRunning := Time.Elapsed
var milliseconds := timeRunning mod 1000
var seconds := timeRunning div 1000 mod 60
var minutes := timeRunning div 60000
locate (1, maxcol - 4 - length (Str.Trim (intstr (seconds))) - length (Str.Trim (intstr (minutes))))
put minutes, ":", seconds, ".", milliseconds

end Timer

%Movement
proc MOVEMENT
%% LEFT & RIGHT
if chars (KEY_LEFT_ARROW) and whatdotcolour (posx - 10, posy + 24) not= black then

sprite := pic1
z:=z+20
elsif chars (KEY_RIGHT_ARROW) and whatdotcolour (posx + 10, posy + 24) not= black then

sprite := pic
z:=z-20
else
velx := 0
end if

%JUMPING
if chars (KEY_UP_ARROW) and posy < maxy - 25 and whatdotcolor (posx, posy - 10) = black then
vely := jump_speed
end if

%gravity
vely -= gravity
posx += round (velx)
posy += round (vely)


if vely < -25 then
vely := -25
end if


if whatdotcolour (posx, posy) = black then
gravity := 0
vely := 0
posy += 10
elsif whatdotcolour (posx, posy + 50) = black then
vely := 0
else
gravity := 10
end if


%% HP%%%
if whatdotcolour (posx + 10, posy + 48) = green then
HP += 1
elsif whatdotcolour (posx + 10, posy) = green then
HP += 1
elsif whatdotcolour (posx - 10, posy + 48) = green then
HP += 1
elsif whatdotcolour (posx - 10, posy) = green then
HP += 1
else
HP := HP
end if

if HP > HL then
HP := HL
end if

%%%Damage%%%
if whatdotcolour (posx + 10, posy + 48) = red then
HP -= damage
elsif whatdotcolour (posx + 10, posy) = red then
HP -= damage
elsif whatdotcolour (posx - 10, posy + 48) = red then
HP -= damage
elsif whatdotcolour (posx - 10, posy) = red then
HP -= damage
else
HP := HP
end if

%teleport
if whatdotcolour (posx, posy + 24) = blue and chars (' ') then
posx := 410
posy := 100
end if

if whatdotcolour (posx, posy + 24) = brightblue and chars (' ') then
posx := 175
end if

end MOVEMENT

%Drawing
proc MAIN
cls
Pic.Draw (map (2), z, 0, picCopy)
MOVEMENT
Pic.Draw (map (1), z, 0, picCopy)
Timer
Pic.Draw (sprite, posx - 10, posy - 7, picMerge)

drawfillbox (1, maxy - 8, HP, maxy - 1, 9) %inside healthbox

if HP < 70 then
drawfillbox (1, maxy - 6, HP, maxy - 1, 43)
end if
if HP < 40 then
drawfillbox (1, maxy - 6, HP, maxy - 1, red)
end if
drawbox (1, maxy - 8, HL, maxy - 1, black) %health box outline
View.Update

end MAIN
var rayman : int := Pic.FileNew ("rayman2.jpg")
rayman := Pic.Scale (rayman, maxx, maxy)
Pic.Draw (rayman, 0, 0, picCopy)

loop
Input.KeyDown (chars)
if chars (KEY_ENTER)then
exit
end if
View.Update
end loop
%Characters
loop
Input.KeyDown (chars)



if chars ('q') then
exit
end if
%Hp Bar
if chars ('v') then
HP := 150
HL := 150
drawfillbox (1, maxy - 8, HP, maxy - 1, 9) %inside healthbox

if HP < 160 then
drawfillbox (1, maxy - 6, HP, maxy - 1, 43)
end if
if HP < 60 then
drawfillbox (1, maxy - 6, HP, maxy - 1, red)
end if
drawbox (150, maxy - 8, HL, maxy - 1, black) %health box outline
View.Update
end if

if chars ('c') then
HP := 200
end if

if chars ('z') then
jump_speed := 80
elsif chars ('x') then
jump_speed := 60
end if

if HP < 1 then
put "Game Over!"
delay (1000)
exit
end if
MAIN
delay (50)

end loop

Window.Close (win)
Tony




PostPosted: Fri May 14, 2010 8:03 pm   Post subject: Re: Final Project for gr 11 Computer Science... side scroller problem

Monduman11 @ Fri May 14, 2010 7:29 pm wrote:
what happens when i want to reach the edge? does the screen keep on trying to move or does it just stay there when its the end of the map?

There could be special cases for starting/ending the map. The detail could be nice, but it introduces complexity and is not necessary for the game. Some platformer games just surround their levels with walls, so that the player can never reach the edge of the visible map.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Monduman11




PostPosted: Fri May 14, 2010 8:07 pm   Post subject: Re: Final Project for gr 11 Computer Science... side scroller problem

Tony @ Fri May 14, 2010 8:03 pm wrote:
Monduman11 @ Fri May 14, 2010 7:29 pm wrote:
what happens when i want to reach the edge? does the screen keep on trying to move or does it just stay there when its the end of the map?

There could be special cases for starting/ending the map. The detail could be nice, but it introduces complexity and is not necessary for the game. Some platformer games just surround their levels with walls, so that the player can never reach the edge of the visible map.

i have a basic wall made that the collision detection should stop at the only problem is that the character just walks over it Sad and i cant seem to stop it lol
Monduman11




PostPosted: Sat May 15, 2010 9:43 am   Post subject: Re: Final Project for gr 11 Computer Science... side scroller problem

well thank you for the help ill see what i can do and how to fix the wall problem... i will try to figure out the rest by myself but if i cant ill come back here cause you guys are really helpful. thank you for everything again
Monduman11




PostPosted: Sat May 15, 2010 12:45 pm   Post subject: Re: Final Project for gr 11 Computer Science... side scroller problem

umm i have another question... how would you make the character shoot things from its mouth or hands. either or. i know it has something to do with the position of the character but other than that im stuck
Riddler




PostPosted: Thu Jun 02, 2011 6:41 pm   Post subject: RE:Final Project for gr 11 Computer Science... side scroller problem

kk could someone help me it is like that problem but easier please my problem is i cant get my background to move and also how to make gravity so my charcter isnt just floating or keep going up
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 18 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: