Author Topic: [Project] Ahead  (Read 10255 times)

0 Members and 2 Guests are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [Project] Ahead
« Reply #15 on: December 22, 2010, 04:42:17 pm »
for side scrolling you could just use "Horizontal -"  ;)

I don't know how to use it :( I will learn it later. Not now.

Code: [Select]
If pxl-Test(X,Y+9)=0
Y-1->Y
End

What do you think of this?

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: [Project] Ahead
« Reply #16 on: December 22, 2010, 04:44:47 pm »
just use "Horizontal -"  All it does is shift the screen to the left on pixel, put that inside the main loop, and it scrolls everything.  This also means you'll have to constantly update the "floor"

also, your problem may be that your using Y+9, it should be Y+8.  ;)  PLus you should also pxl-Test(X+7,Y+8) as well as pxl-test(X,Y+8)
« Last Edit: December 22, 2010, 04:45:37 pm by yunhua98 »

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [Project] Ahead
« Reply #17 on: December 22, 2010, 04:53:36 pm »
just use "Horizontal -"  All it does is shift the screen to the left on pixel, put that inside the main loop, and it scrolls everything.  This also means you'll have to constantly update the "floor"

also, your problem may be that your using Y+9, it should be Y+8.  ;)  PLus you should also pxl-Test(X+7,Y+8) as well as pxl-test(X,Y+8)

Code: [Select]
If pxl-Test(X,Y+8)
Y-1->Y
End
If pxl-Test(X+7)
X-1->X
End

The 7 will depend on which sprite I use. Code okay?

« Last Edit: December 22, 2010, 05:04:20 pm by ScoutDavid »

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: [Project] Ahead
« Reply #18 on: December 22, 2010, 05:05:10 pm »
the x-1->x part will make the sprite float up if there is ground underneath.  ???

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: [Project] Ahead
« Reply #19 on: December 22, 2010, 05:07:37 pm »
Ah, wait.  For the code I posted, I forgot to add a 'ClrDraw'.
Immediately after the 'DispGraph', add a 'ClrDraw', and it should work better.
I've edited the code I posted to match. (I also changed the collision detection part slightly to match yunhua98's advice)
« Last Edit: December 22, 2010, 05:11:13 pm by Michael_Lee »
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: [Project] Ahead
« Reply #20 on: December 22, 2010, 05:12:04 pm »
the x+7 checks for the pixel below the sprite on the bottom right corner.  ;)

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [Project] Ahead
« Reply #21 on: December 22, 2010, 05:12:45 pm »
Code: [Select]
.PLATFORM
Fix 5

[3810385410282828]->Pic0
[FFFFFFFFFFFFFFFF]->Pic1
0->X
40->Y

ClrDraw

.Main game loop
While 1

  .Moving right
  If getKey(3)
    X+2->X
  End

  .Jumping
  If getKey(4) and (Y>0)
    Y-5->Y
  End

  .Create floor
  For(A,0,12
    Pt-On(A*8,48,Pic1)
  End

  .Collision test (ground) and Gravity
  !If pxl-Test(X,Y-8)
    !If pxl-Test(X+7,Y-8)
      Y+1->Y
    End
  End

  .Display sprite
  Pt-On(X,Y,Pic0)

  .Display the screen
  DispGraph
  ClrDraw

  .Close Game
  If getKey(15)
    Fix 4
    Return
  End

End

Thanks, I made a similar one, using yunhua's advices, though, I'll be using mine, though :) Thanks much anyways

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: [Project] Ahead
« Reply #22 on: December 22, 2010, 05:14:06 pm »
@Yunhua98: Yeah, I forgot about that, although in the current setup, it doesn't actually matter much because the floor is just completely flat.  But you would need that for any uneven floors.
« Last Edit: December 22, 2010, 05:15:45 pm by Michael_Lee »
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [Project] Ahead
« Reply #23 on: December 22, 2010, 05:17:41 pm »
So, I need three pxl-Tests? I'm also thinking about the top right corner and below right corner. Would that make it 4 pxl-tests?

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: [Project] Ahead
« Reply #24 on: December 22, 2010, 05:26:45 pm »
That depends.
Assuming that the floor won't be flat 100% of the time, and assuming that you can run into things unless you jump, you'd probably need 3 pxl-Tests.
If it's possible to jump up and hit a ceiling (which could also be uneven), then 4 pxl-Tests

Code: [Select]
#       #
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 #       #
If the X's are your sprite, then the # would be where the pxl-Tests should probably be given your current setup.
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [Project] Ahead
« Reply #25 on: December 22, 2010, 05:29:48 pm »
Code: [Select]
    #    #
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
    #    #

Actually this since I can't go back.
« Last Edit: December 22, 2010, 05:32:36 pm by ScoutDavid »

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: [Project] Ahead
« Reply #26 on: December 22, 2010, 05:35:20 pm »
No, not really, what if you were inching forward very slowly on a platform...

Code: [Select]
    #    #
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
    #    #
@@@
@@@
@@@
@@@
@@@
Then you would fall off, and through the platform.
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [Project] Ahead
« Reply #27 on: December 22, 2010, 05:37:51 pm »
No, not really, what if you were inching forward very slowly on a platform...

Code: [Select]
    #    #
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
 XXXXXXXX
    #    #
@@@
@@@
@@@
@@@
@@@
Then you would fall off, and through the platform.

You are very clever, I understood that, adding more pxl-Tests nows.

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: [Project] Ahead
« Reply #28 on: December 22, 2010, 05:41:37 pm »
Wait, adding more?
I don't think you need to add more, just shift the locations a bit.

As long as any surface you encounter is 8 pixels wide (or more), the locations of the pxl-Tests I gave earlier should be enough to cover everything.
(Of course, if you plan on adding surface areas less then 8 pixels wide, then more would be needed)
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [Project] Ahead
« Reply #29 on: December 22, 2010, 05:45:15 pm »
Code: [Select]
.Collision test (ground) and Gravity
  !If pxl-Test(X,Y+8)
    !If pxl-Test(X+7,Y+8)
      Y+1->Y
    End
  End

  If pxl-Test(X+7,Y)
     X-1->X
  End

I have these at the moment :S