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

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
[Project] Ahead
« on: December 22, 2010, 07:26:03 am »
Ahead is the title of my next Axe calculator game: a platformer where you cannot go back. That's right, you can't go back.

Here's an initial screenshot, with a very concerning bug:



No, I will not be using someone else's code as a base. It's all mine this time.

I actually started this program with the help of Ashbad but I deleted the whole code (on purpose) because it was very messy and started it all over again.

Code: [Select]
.PLATFORM
[3810385410282828->Pic0
[FFFFFFFFFFFFFFFF->Pic1

0->X
40->Y

While 1

ClrDraw



Pt-On(X,Y,Pic0

For(A,0,96
Pt-On(A,48,Pic1
A+7->A
End

DispGraph

.pxl-Test(X,Y)r  Returns 1 if pixel is black and 0 if pixel is white on the back buffer at (X,Y).

If pxl-Test(X,Y+8)r=0
Y+1->Y
Else
End

If getKey(3)
X+2->X
End

If getKey(4)
Y-2->Y
End

End

This is my code, I made a pxl-Test collision check to avoid the character to drop below the floor, but it doesn't seem to work very well.

That's the only help I need at the moment, thanks :)

Offline Munchor

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

[3810385410282828]->Pic0
[FFFFFFFFFFFFFFFF]->Pic1

0->X
40->Y

.Game Loop
While 1

StorePic
.Display Sprite in given coordinates

Pt-On(X,Y,Pic0


For(A,0,96
Pt-On(A,48,Pic1
A+7->A
End


DispGraph

Pt-Change(X,Y,Pic0
RecallPic


.Key Events
If getKey(3)
X+2->X
End

If pxl-Test(X,Y-8) = 0
Y+1->Y
End

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

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

.End of Game Loop
End

Recycled some of the old code and added a CLEAR button function. I am starting to figure out how to make gravity work :)

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: [Project] Ahead
« Reply #2 on: December 22, 2010, 01:17:16 pm »
First, I highly recommend that you add ending parenthesis.
Doing
Code: (Bad Example) [Select]
For(A,0,100
  If A=(rand^100
    Pt-On(10,10,Pic1
  End
End
is no different (and is equally optimized) compared to
Code: (Good Example) [Select]
For(A,0,100)
  If A=(rand^100)
    Pt-On(10,10,Pic1)
  End
End
Also, not adding parenthesis can do very odd things to your code, and because they don't give you a speed increase like it does in Basic, you should probably just add them.
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 #3 on: December 22, 2010, 01:19:30 pm »
Yes, since it is converted to Assembly, it doesn't mater. Thanks, it's just that I learnt that in Basic :P

I just made another file, but it doesn't have gravity :S

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: [Project] Ahead
« Reply #4 on: December 22, 2010, 01:53:52 pm »
Also, because I needed a break from what I was doing, I simplified parts of your code:
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 Y>0 and getKey(4)
    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

Not sure why you were using StorePic and RecallPic, but I think those were the cause of your problems.
« Last Edit: December 22, 2010, 05:21:24 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 DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Project] Ahead
« Reply #5 on: December 22, 2010, 01:56:47 pm »
I would like to see some more platformer games for calcs. I hope you can solve the collision detection issue. I personally had troubles with it before. if you need help with physics, you might want to ask Builderboy, since he's pretty good at it. I believe someone else here did too. He helped me with the physics in Supersonic Ball. Good luck!

Ashbad

  • Guest
Re: [Project] Ahead
« Reply #6 on: December 22, 2010, 02:09:59 pm »
I can help with physics too, I'm pretty decent at it, though builderboy might be better ;)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Project] Ahead
« Reply #7 on: December 22, 2010, 02:13:09 pm »
Ah ok I wasn't sure, because physics is not something a lot of people know. They can be very hard to deal with sometimes. In my case, my gripe is how to detect when you reach a solid tile when your character moves at more than 1 pixel per frame.

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: [Project] Ahead
« Reply #8 on: December 22, 2010, 02:18:42 pm »
Yeah, collision detection can be a major PITA at times.

In the project I'm working on right now, I'm trying a method where each time I make an object move (they're sort of like bullets), I see if their x and y coordinates are within a certain range of my character.  I'm not too sure if that might work for tiles, though.
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 shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: [Project] Ahead
« Reply #9 on: December 22, 2010, 02:40:29 pm »
that works well for bullets and such, as it doesn't matter if the two objects pass through one another(bullets disappear when colliding with the player), but with platform detection the programmer has to use a for( loop or something similar to check every pixel in between the character's current position and the desired one to ensure that the two don't pass through one another. it's not all that difficult, and i would be willing to help if asked.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Project] Ahead
« Reply #10 on: December 22, 2010, 02:52:26 pm »
Yeah what Shmibs said. That's what JustCause did actually. I heard that if you do it wrong, it can run very slow, though.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [Project] Ahead
« Reply #11 on: December 22, 2010, 03:45:24 pm »
I just tried Michael Lee's code without making any changes xD

I had a new idea for gravity, though :)

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 #12 on: December 22, 2010, 04:31:32 pm »
I've made a similar platformer that only moves in one direction, but its not done because of collision detection with incoming obstacles.  What I did for jumping was have a variable called J for whether he's jumping or not, a var F for whether he's falling or not, and T as a timer, and V as the vertex, where he stays put in the air for 2-3 frames.  (bad physics.  :P)

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 #13 on: December 22, 2010, 04:33:59 pm »
I've made a similar platformer that only moves in one direction, but its not done because of collision detection with incoming obstacles.  What I did for jumping was have a variable called J for whether he's jumping or not, a var F for whether he's falling or not, and T as a timer, and V as the vertex, where he stays put in the air for 2-3 frames.  (bad physics.  :P)

That might have worked better than mine, but seems confusing :S

After physics, I'll start sidescrolling :)

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 #14 on: December 22, 2010, 04:35:26 pm »
for side scrolling you could just use "Horizontal -"  ;)

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>