Author Topic: Scrolling problem; please help!  (Read 9360 times)

0 Members and 1 Guest are viewing this topic.

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Scrolling problem; please help!
« on: February 08, 2012, 04:56:59 pm »
So I've been working on a (non-smooth-)scrolling engine in my spare time at school and it mostly works the way I want it to so far. When you move in any direction and you're not on the edge of the map, it shows the next block, like in the screenshot (I haven't implemented collision yet). However, as you can tell, it works in every direction but up! D: I haven't gone through and optimized yet, but I'm going to provide the code for the moving bit. I honestly can't tell why it's not working because the code for each conditional is exactly the same. Please help!

Spoiler For moving code:
X and Y are the person's coordinates on-screen, and Z and [theta] are the coordinates of the top-left corner of where I'm displaying the map from.

..MOVING
If getKey(2)
 If X>1
  X--
 Else
  If Z>0
   Z--
  Else
   X-(X!=0)->X
  End
 End
ElseIf getKey(3)
 If X<10
  X++
 Else
  If Z<(W-12
   Z++
  Else
   X+(X!=11)->X
  End
 End
ElseIf getKey(1)
 If Y<6
  Y++
 Else
  If [theta]<(H-8
   [theta]++
  Else
   Y+(Y!=7)->Y
  End
 End
ElseIf getKey(4)
 If Y>0
  Y--
 Else
  If [theta]>0
   [theta]--
  Else
   Y-(Y!=0)->Y
  End
 End
End

EDIT: If need-be, I can provide all of my code. It really has nothing special to it at the moment.
« Last Edit: February 08, 2012, 05:00:14 pm by BlakPilar »

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Scrolling problem; please help!
« Reply #1 on: February 08, 2012, 05:02:19 pm »
If Y>0?
Should the 0 be more if you want to not go to the edge?
(unless I'm reading the code wrong)

Wait, what's the problem?
« Last Edit: February 08, 2012, 05:03:44 pm by epic7 »

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: Scrolling problem; please help!
« Reply #2 on: February 08, 2012, 05:12:22 pm »
Yeah, I got it ;D I just needed to change Y>0 to Y>1 lol. Thanks, though!

Offline thydowulays

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 184
  • Rating: +12/-1
  • Don't gimme dat lip
    • View Profile
    • Thy Gaming Forum
Re: Scrolling problem; please help!
« Reply #3 on: February 08, 2012, 05:36:16 pm »
I would actually love if you could provide the all the code for this. I want to get a (non-smooth) scrolling tilemapper up for my game Nulled, and this is EXACTLY what I needed. Thanks!
Current Projects:
-Sparta GUI Library: 25% - Alpha Stage
-Grapher - 75% - Beta Stage *on hiatus




Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Scrolling problem; please help!
« Reply #4 on: February 08, 2012, 05:40:46 pm »
I'm actually thinking of turning Caedes into a scroller, and your code would help me too :)
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: Scrolling problem; please help!
« Reply #5 on: February 08, 2012, 09:04:03 pm »
Woah, sorry guys x.x lol. It's okay now though, I sent it to you both :D

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Scrolling problem; please help!
« Reply #6 on: February 08, 2012, 09:04:45 pm »
these things have been posted dozens of times before. just try poking around the forums for one.
the axe routines thread is a great place to start when looking for that type of thing, and a quick forum search yielded these threads(one of which you started yourself, saintrunner):
http://ourl.ca/7512
http://ourl.ca/11302
http://ourl.ca/12349
http://ourl.ca/9188
http://ourl.ca/14065

tilemapping in axe is basically the most asked, and consequently most well documented, routine on this site.

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Scrolling problem; please help!
« Reply #7 on: February 08, 2012, 09:08:26 pm »
Yeah, I got a big chunk of a nonsmooth scrolling tilemap done....not smooth though
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Scrolling problem; please help!
« Reply #8 on: February 08, 2012, 09:20:00 pm »
like i said, look in the routines thread. it has more than one example of smooth scrolling in there. here's one builder posted two years ago(works only for left and right):
http://www.omnimaga.org/index.php?action=dlattach;topic=1532.0;attach=862

and one i posted seven months later(works for all four directions):
http://ourl.ca/4129/122642
« Last Edit: February 08, 2012, 09:23:07 pm by shmibs »

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: Scrolling problem; please help!
« Reply #9 on: February 09, 2012, 07:25:48 am »
I don't really venture into the routines thread because I want to find things out by myself. When I understood the basic meaning behind yunhua's smooth-scrolling engine, I decided to try my own one and haven't actually gotten around to fiddling around with it until recently (partly because I just finished Inheritance [awesome book, imo]).

Plus most of the mistakes I make are small silly ones and I eventually end up finding them.

Offline turiqwalrus

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 840
  • Rating: +51/-2
  • Wheeeeeee~!
    • View Profile
Re: Scrolling problem; please help!
« Reply #10 on: February 09, 2012, 11:54:38 am »
I don't really venture into the routines thread because I want to find things out by myself.
makes sense. I try to learn stuff by myself as well :D
partly because I just finished Inheritance [awesome book, imo]
agreed!