http://calcg.org/newlogo2.png Not Logged in.
Login | Register

General Discussion Board \ Calculator Programming \ Xlib Scrolling in all 2 directions.

Click here to log in (you must be logged in to post comments).

AuthorComment
1337h4kor
Wraith
avatar
Posted: 17 Oct 2007
19:33 GMT
Total Posts: 612
Ok I was wondering how the code would look for an engine when scrolling in 2 directions. The example that's included in the documentation looks pretty good but it doesn't really help with boundary questions when using 2 directions. Like what to do if a character was at a said position. 4 would also help. Basically I'd appreciate any info on 2 directions.

---
I wish i could swim in the sea of probabilty but once during my life.
Vectris
Ultralisk
avatar
Posted: 19 Oct 2007
18:24 GMT
Total Posts: 375
Wow u kind of lost me with the "scrolling in 2 directions..." do u mean how the engine for a game in which u can scroll along one x-coordinate (left and right) would look with xLib?
1337h4kor
Wraith
avatar
Posted: 19 Oct 2007
21:53 GMT
Total Posts: 612
Yes two directions left and right.

---
I wish i could swim in the sea of probabilty but once during my life.
CoffmanRunner
Ultralisk
avatar
Posted: 20 Oct 2007
06:13 GMT
Total Posts: 235
well you have to use a matrix for mapping with sprites (and i am assuming you are having xlib draw the whole map not just each sprite one by one) and if you are using a matrix you know where the character is and you can do a simple
X //char X cord
Y //char Y cord
L1 //X cord of special objects
L2 //Y cord of special objects


:Code:
For(Z,1,length(L1)
If (X= sub(L1,1,Z)) and (Y= sub(L2,1,Z))
prgm(seprate program or Goto that take you to a place where it decides what to do - DONT put this code in your move engine becasue it will slow it down)
:End Code:

Is this what you are asking about?

---
Never gonna let you down...
1337h4kor
Wraith
avatar
Posted: 20 Oct 2007
21:07 GMT
Total Posts: 612
Wells sort of I guess that I shall try. Kevin is supposedly supposed to help me on Maxcoderz but I'm not sure how long it will take.

---
I wish i could swim in the sea of probabilty but once during my life.
Hydraliskisback
Wraith
avatar
Posted: 25 Oct 2007
20:03 GMT
Total Posts: 583
hmm i did this, if your talking about the same thing.
when you press left, then the screen moves left, yes?

screenvarX==B
screenvarY==A
mapvarX==D
mapvarY==C
screenvar, placement on screen
map var, placement on map
maxXvar==F
maxYvar==E
minXvar==H
minYvar==G
on the display map, you can tell it to display a certain sector of the map, tell that sector to move with this:
x=2 is press left button btw


real(8
Ans->X
if X=2
then
if B=8 and H!=4
then
H-4->H
F-4->F
end
if B<=8 and H<=4 and B!=0 (<= is less than or equal to)
B-4->B
if B>8
B-4->B
end

its a bit long, but it doesnt lag that much. i used it once, and it worked surprisingly fast, for all four directions.

or at the if x=2
then make it goto a program such as "ML" or moveleft.
soya

---
Iff Hydralisk has posted the above, the above is stupid.
1337h4kor
Wraith
avatar
Posted: 26 Oct 2007
15:42 GMT
Total Posts: 612
So that should work for a simple side scroller?

---
I wish i could swim in the sea of probabilty but once during my life.
Hydraliskisback
Wraith
avatar
Posted: 27 Oct 2007
10:39 GMT
Total Posts: 583
same thing as i posted
just for only the left and right directions

---
Iff Hydralisk has posted the above, the above is stupid.





Portal | My Account | Register | Lost Password or Username | TOS | Disclaimer | Help | Site Search | File Archives Copyright © 2002-2019 CalcG.org