Author Topic: Side Project #2: DUNGEON  (Read 26344 times)

0 Members and 5 Guests are viewing this topic.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Side Project #2: DUNGEON
« Reply #30 on: May 09, 2009, 12:43:05 am »
I figured it out, and I also figured out how to detect the way it is, I'll post my code in a bit.
Code: [Select]
:For(A,1,8)
:Text(‾1,8A-8,0,sub(Str1,15A-14,15
:StorePic 2
:Text(‾1,8A-8,0,sub(Str2,15A-14,15
:RecallPic 2
:End
:2→B:3→A
:DelVar J
:While 1
:A→C
:B→D
:Text(‾1,8A-8,6B-6,"Ω
:DelVar K
:getKey→K
:If K:Then
:B+(K=26)-(K=24→B
:If B≠D
:Then
:If ""=sub(Str1,15A-14+B-1,1
:D→B
:End
:End
:If ""≠sub(Str1,15(A+1)-14+B-1,1
:Then
:A+1→A
:If J:A-1→A
:Else
:J+L1(1)(K=21→J
:End
:If J:Then
:A-1→A
:J-1→J
:End
:If A≠C or B≠D
:Then
:Text(‾1,8A-8,6B-6,"Ω
:Text(‾1,8C-8,6D-6,"
:End:End
it runs pretty quickly on the 83+. this version also includes spikes and stuff.
/e

Offline simplethinker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 695
  • Rating: +16/-5
  • snjwffl
    • View Profile
Re: Side Project #2: DUNGEON
« Reply #31 on: May 09, 2009, 12:59:42 am »
@simplethinker, isn't inString( slow, though? I remember testing it and it wasn't too fast from what I remember, compared to what i am doing atm
That's a good point.  From my tests inString( is taking 25% more time than using =.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true." -- Professor Robert Silensky



Chip's Challenge: ħ%

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: Side Project #2: DUNGEON
« Reply #32 on: May 09, 2009, 01:01:15 am »
This is why I eventually opted for limited walking area tiles in Illusiat. Not that I really need that much, anyway, though. For event triggers tiles, I can simply make an animation of the character walking on the tile if it's a switch, anyway

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Side Project #2: DUNGEON
« Reply #33 on: May 09, 2009, 01:01:26 am »
unless of course you are trying for a very large string right?
/e

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: Side Project #2: DUNGEON
« Reply #34 on: May 09, 2009, 01:04:45 am »
This doesn't matter. I only have two walk-on-able character to check in Illusiat (" " and "=", the latet being stairs) and when I hit a wall it's only when the event tiles are checked for, to speed up walking around

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
Re: Side Project #2: DUNGEON
« Reply #35 on: May 09, 2009, 01:01:08 pm »
I use inString( for what I'm doing, and it's decently fast, and if you had a lot of tiles that could be walked on, then it would be even more efficient, although I guess it's not really efficient when you only have 1 tile you can walk on...hmm I might need to change my code now.
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Side Project #2: DUNGEON
« Reply #36 on: May 09, 2009, 01:55:35 pm »
I don't use Instring( yet because I am only testing for one right now, but I may add more ones later.

I wonder which one of ours is faster right now? (I'm using a TI-83+ ROM)
oh yeah, those "..." tiles are monkey bars which my character is climbing across
/e

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
Re: Side Project #2: DUNGEON
« Reply #37 on: May 09, 2009, 02:08:50 pm »
yours is probably faster now because I have a bunch of other stuff going on at the same time (well not a 'bunch', but you know what I mean).

Heh seeing your ss makes me want to finish this...time to get back to map designing..bleh
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
Re: Side Project #2: DUNGEON
« Reply #38 on: May 09, 2009, 02:10:59 pm »
I figured it out, and I also figured out how to detect the way it is, I'll post my code in a bit.
Code: [Select]
:For(A,1,8)
:Text(‾1,8A-8,0,sub(Str1,15A-14,15
:StorePic 2
:Text(‾1,8A-8,0,sub(Str2,15A-14,15
:RecallPic 2
:End
:2→B:3→A
:DelVar J
:While 1
:A→C
:B→D
:Text(‾1,8A-8,6B-6,"Ω
:DelVar K
:getKey→K
:If K:Then
:B+(K=26)-(K=24→B
:If B≠D
:Then
:If ""=sub(Str1,15A-14+B-1,1
:D→B
:End
:End
:If ""≠sub(Str1,15(A+1)-14+B-1,1
:Then
:A+1→A
:If J:A-1→A
:Else
:J+L1(1)(K=21→J
:End
:If J:Then
:A-1→A
:J-1→J
:End
:If A≠C or B≠D
:Then
:Text(‾1,8A-8,6B-6,"Ω
:Text(‾1,8C-8,6D-6,"
:End:End
it runs pretty quickly on the 83+. this version also includes spikes and stuff.
whoa just saw this. I'll post my code for you in a sec.

Code: [Select]
While Q>0 // Q=Health

G-(G>0->G  // This is my 'if you jumped' variable
H+not(G->H  // This is my gravity variable.

If E=1 // If there's an enemy in the room
Then
prgmZ4
End

If not(G) and not(fPart(H/2)) and not(inString(Str0,sub(Str2,T+14,1  // more gravity stuff
Then
Text(-1,8D-16,6C-12,"
T+14->T // Location in string
D+1->D // Player (Y) variable
If D>9 // If you go below the map
Then
M+1->M
2->D
14+C->T
prgmZ1
End
Text(->1,8D-16,6C-12,"Ê
End

getKey->K

If K=25 // if you jump
Then
If (inString(Str0,sub(Str2,T+14,1 // makes sure you're on a tile and not in the air
Then
4+2(1=L(1->G // Sets your jump to '4' or '6'
End
End

If G>0 and not(fPart(G/2)) and not(inString(Str0,sub(Str2,T-14,1 // if your 'jump' is still activated and nothing is above you
Then
Text(-1,8D-16,6C-12,"
D-1->D
T-14->T
If D<2  // if you went above the map
Then
9->D
M-1->M
14D-14+C->T
prgmZ1
End
Text(-1,8D-16,6C-12,"Ê
End

If (D=I and C=J) or sub(Str2,T,1)!=" " // if you hit an enemy or walked onto something
Then
prgmZ3
End

If (K=24 or K=26) and not(inString(Str0,sub(Str2,T-(K=24)+(K=26),1 // if left or right was pressed AND nothing is in the way
Then
Text(-1,8D-16,6C-12,"
C-(K=24)+(K=26->C
T-(K=24)+(K=26->T
If C<2 or C>13 // If you went outside the map
Then
L+(C>13)-(C<2->L
13(C<2)+2(C>13->C
14D-14+CüT
prgmZ1
End
Text(-1,8D-16,6C-12,"Ê
If (D=I and C=J) or sub(Str2,T,1)!=" "
Then
prgmZ3
End
End

If max(K={24,25,26  // Just here to fix a bug that I had found, you don't need to worry about it
Then
If "x"=sub(Str2,T-(K=26)+(K=24)+14(K=25),1
Then
Text(ú1,8(D+(K=25))-16,6(C+(K=24)-(K=26))-12,"!
StorePic 1
Text(ú1,8(D+(K=25))-16,6(C+(K=24)-(K=26))-12,"x
RecallPic 1
End
End

End
The 'not(fPart(H/2' and 'not(fPart(G/2' are both put in to slow down the game.. essentially they're only run when those variables are even, which happens every OTHER time the loop is run.
« Last Edit: May 09, 2009, 02:33:35 pm by trevmeister66 »
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Side Project #2: DUNGEON
« Reply #39 on: May 09, 2009, 02:33:38 pm »
thanks, I'll take a look, and maybe I'll find some optimizations :P
I haven't added in moving enemies, but I still haven't optimized my code, so mine is slower then it could be.
/e

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
Re: Side Project #2: DUNGEON
« Reply #40 on: May 09, 2009, 02:35:06 pm »
yeah I saw a bunch of things you could make faster. I have one question about your code though, why are you using C and D as well as A and B for your characters location?
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Side Project #2: DUNGEON
« Reply #41 on: May 09, 2009, 03:22:56 pm »
A and B are the current location, C and D are the ones I'm using for saving my location in case I need to revert it back
/e

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
Re: Side Project #2: DUNGEON
« Reply #42 on: May 09, 2009, 03:28:27 pm »
Why not just keep C and D as your location, since you use A for displaying the map? Would save quite a few bytes.
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Side Project #2: DUNGEON
« Reply #43 on: May 09, 2009, 03:53:22 pm »
because I need to be able to revert back a few times, read this:
Code: [Select]
:For(A,2,9) ;
:Text(‾1,8A-2(8),0,sub(Str1,15A-(14+15),15 ;this is my
:StorePic 2 ;dual text
:Text(‾1,8A-2(8),0,sub(Str2,15A-(14+15),15 ;sprite engine
:RecallPic 2 ;
:End
:L1(4→B:L1(5→A ;store initial starting point
:DelVar J ;delete jump variable
:Text(‾1,8,90,L1(2 ;display health
:While A≠1 and A≠10 and B≠1 and B≠15 and L1(2 ;check to make sure that you have health and are not on edge of map
:A→C ;store Y
:B→D ;store x
:Text(‾1,8A-8,6B-6,"Ω ;display character
:If L1(3 ;if you are on a spike
:Then
:2→L1(3
:Text(‾1,8A-8,6B-6,"* ;replace spike sprite
:End
:DelVar K ;I have no idea why I put it here...I'll get rid of it
:getKey→K ;store key press
:If K:Then ;if keypress
:B+(K=26)-(K=24→B ;movement
:If B≠D ;tests to see if you moved
:Then
:If ""=sub(Str1,15A-14+B-1,1 ;tests to make sure you are moving onto a blank spot
:D→B ;if not, revert x
:End
:End
:If ""≠sub(Str1,15(A+1)-14+B-1,1 ;if you are not above a tile
:Then
:A+1→A ;gravity happens
:If J:A-1→A ;unless you are jumping
:Else
:J+L1(1)(K=21→J
:End
:If J:Then ;if you are jumping
:If ""≠sub(Str1,15(A-1)-14+B-1,1 ;test to make sure there is a blank above you
:Then
:A-1→A ;if not, you stay still
:End
:J-1→J ;minus one to jump time
:End
:If A≠C or B≠D ;if you have moved
:Then
:Text(‾1,8A-8,6B-6,"Ω ;move character
:Text(‾1,8C-8,6D-6," ;clear last spot you were on
:If 2=L1(3 ;if you were on a spike
:Then
:Text(‾1,8C-8,6D-6,"* ;reset spike sprite
:0→L1(3 ;clear spike flag
:End
:End
:If Instring("Δ*~",sub(Str1,15A-14+B-1,1 ;If you are on something that does something to you
:then
:If "Δ"=sub(Str1,15A-14+B-1,1 ;if on a health pack
:Then
:L1(2)+3→L1(2 ;add health!
:If 9<L1(2 ;but keep it below 10
:9→L1(2
:sub(Str1,15A-14+B,length(Str1)-15A-14+B→Str3 ;get rid of health from map
:sub(Str1,1,15A-14+B-2→Str1 ;still get rid of it
:Str1+" "+Str3→Str1 ;piece together map
:Text(‾1,8,90,L1(2
:Pause "HEALTH +3 ;tell the player what happened
:End
:If "~"=sub(Str1,15A-14+B-1,1 ;this is actually a small 0, but there is no equvalent on computers
:Then
:Pause "JUMP BOOST ;tell them that they are one step closer to flying
:sub(Str1,15A-14+B,length(Str1)-15A-14+B→Str3 ;delete boost
:sub(Str1,1,15A-14+B-2→Str1 ;delete I say!
:Str1+" "+Str3→Str1 ;now replace
:L1(1)+1→L1(1 ;actually give them the upgrade
:End
:If "*"=sub(Str1,15A-14+B-1,1 ;if you are on a spike
:Then
:L1(2)-1→L1(2 ;lower health
:Text(‾1,8,90,L1(2 ;update health in corner
:1→L1(3 ;set spike flag
:End
:End
:If "..."=sub(Str1,15(C-1)-14+D-1,1 ;if on monkey bars
:Then
:If A>C ;and gravity is making you fall
:Then
:A-1→A ;don't!
:Text(‾1,8(A+1)-8,6B-6," ;clear the sprite that is falling
:End
:End
:End
:A→L1(4 ;store new y
:B→L1(5 ;store new x
/e

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
Re: Side Project #2: DUNGEON
« Reply #44 on: May 09, 2009, 05:07:46 pm »
Hmm I would recommend not using list's for variables that are going to change a lot. Lists are pretty slow and can really slow down your game. Just use a variable for it.

Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)