Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Ki1o

Pages: [1] 2 3 ... 9
1
Axe / Re: Converting from Prgm to App
« on: April 11, 2023, 10:53:14 pm »
@E37 I really need your help. I think I'm close to approaching my wit's end with Axe as a whole. This may seem sudden, but I am continuously running into issues that I simply cannot explain or find a cause for. At this point it is probably safe to assume that the language is bugged in some way or maybe I'm just bad with it. So I'm hoping that you can help me one last time. I was feeling really optimistic earlier, but it seems I can never make any progress on this project without problems. I'll try to explain what I'm experiencing. Right now, all I have is the simple game loop I posted earlier and the Update code along with the tile map code and a single draw function. I took your advice about the input code and optimized to something that worked and I liked. However, adding any more code to this project now seems to break it. It doesn't draw to the screen, it simply quits and says done. I'm going to attach the source so that maybe you can test it whenever you get a chance. The thing that broke the code is anything that I added dealing with changing direction. Which is very trivial and shouldn't break anything, but it does. So please, please help me make sense of this. What am I doing that is so wrong?

2
Axe / Re: Converting from Prgm to App
« on: April 11, 2023, 07:07:17 pm »
@E37 Oh man that RTS game is very very nice. I'd love to check out the source. Is the game running at 6MHz? If so how did you squeeze out such performance while handling grayscale? If not, its still very impressive. I'm also curious about the font. Is that your text axiom? Either way I am definitely interested in learning more.

3
Axe / Re: Converting from Prgm to App
« on: April 11, 2023, 03:07:29 pm »
I am making a state machine for the game, and yeah... I was trying to be... efficient? I was trying to find a way to avoid repeating the same code and I wanted to see if there was a different way instead of using If for each key. I don't know why I also didn't think of simply using If...ElseIf instead. I guess I was fixated on making this specific solution work.
The main game loop itself is pretty simple:
Code: [Select]
Lbl Main
Init()
Game()
Return
Goto MAINEND
Lbl Init
0→Frame→Quit→ScrollXOffset→ScrollYOffset→PlayerX→PlayerY+6*8→MapX→MapY
°TileMap→Map
DrawMap()
ʟUpdateGame→UpdateState
ʟDrawGame→DrawState
Return
Lbl Update
Frame++
(UpdateState)()
Return
Lbl Draw
(DrawState)()
Return
Lbl Game
While 1
Update()
Draw()
EndIf Quit
Return
The idea is that Update and Draw are called every frame which then calls their respective "State" function for that frame. This is opposed to the logic in my code on GitHub where technically, I was doing all of the scrolling within the span of a single game frame. This way, every update and draw call game happens on a per frame basis.
Since I was just working on the movement I haven't added any collision checks yet but I will. I'm also all for code critiques. Honestly, some of my code is a little... weird because I'm also a student so every new CS concept I learn I try to see how it would be done in Axe, resulting in a lot of... pasta

4
Axe / Re: Converting from Prgm to App
« on: April 11, 2023, 03:27:05 am »
@E37 As usual, thanks for all the help! I will definitely be making use of this. I figured dereferencing for each variable would be slow but your idea is wayy better. Idk what I was thinking. I was also thinking of creating one big appvar instead of creating multiple appvars with GetCalc() so I'll definitely be doing that. I've run into a weird little bug/issue with Axe that I cannot explain and I was hoping you would be able give me some answers. What I am currently attempting to do in my rewrite at the moment is ensure that only 1 keypress is registered at a time. I'm following a tutorial series and although it's in another language it's pretty easy to convert to Axe. Anyways, my original input code looked like this:
Code: [Select]
Lbl UpdateGame
If getKey(2)
PlayerX--
⁻8→ScrollXOffset
ʟUpdatePlayer→UpdateState
End
If getKey(3)
PlayerX++
8→ScrollXOffset
ʟUpdatePlayer→UpdateState
End
If getKey(4)
PlayerY--
⁻8→ScrollYOffset
ʟUpdatePlayer→UpdateState
End
If getKey(1)
PlayerY++
8→ScrollYOffset
ʟUpdatePlayer→UpdateState
End
If getKey(15)
ʟUpdateQuit→UpdateState
End
Pause 16
Return
Lbl UpdatePlayer
If ScrollXOffset<<0
ScrollLeft()
End
If ScrollXOffset>>0
ScrollRight()
End
If ScrollYOffset<<0
ScrollUp()
End
If ScrollYOffset>>0
ScrollDown()
End
If ScrollXOffset=0 ? ScrollYOffset=0
ʟUpdateGame→UpdateState
End
Return
Lbl UpdateQuit
1→Quit
Return
However this results in diagonal movement when 2 buttons are pressed, which I don't want. So, following the tutorial I tried this code:
Code: [Select]
Lbl UpdateGame
For(I,1,4)
If getKey(I)
PlayerX+sign{I-1+°DirX}→PlayerX
PlayerX+sign{I-1+°DirY}→PlayerY
sign{I-1°DirX}*8→ScrollXOffset
sign{I-1°DirY}*8→ScrollYOffset
ʟUpdatePlayer→UpdateState
End
End
If getKey(15)
ʟUpdateQuit→UpdateState
End
Pause 16
Return
Lbl UpdatePlayer
If ScrollXOffset<<0
ScrollLeft()
End
If ScrollXOffset>>0
ScrollRight()
End
If ScrollYOffset<<0
ScrollUp()
End
If ScrollYOffset>>0
ScrollDown()
End
If ScrollXOffset=0 ? ScrollYOffset=0
ʟUpdateGame→UpdateState
End
Return
Lbl UpdateQuit
1→Quit
Return
This somehow causes the program to quit straight to the homescreen. I tried to figure out the cause of this by commenting out different lines and testing. If I comment out the lines that dealt with either horizontal movement or vertical movement and scrolling, the program executes just fine. However if all 4 lines of code are present it results in an immediate quit to homescreen. This should be impossible since the game screen hasn't even been drawn. It skips any execution of code and seems to instantly quit and I cannot for the life of me understand why. I'm really hoping that you might have some insight. I can provide the entire source so you can test it yourself if you would like.

5
Axe / Re: Converting from Prgm to App
« on: April 03, 2023, 10:20:52 pm »
Thanks for testing! I started to think it may be the AI and you just confirmed it. I am still moving forward with the rewrite because I realized that there were issues with the way I was handling the turn based game loop, so I'm hoping to eliminate any other unexpected behavior with better code. Also I just want to confirm, there should be no issue using custom variables to call function labels right?

6
Axe / Re: Converting from Prgm to App
« on: March 27, 2023, 09:39:57 pm »
I think I am going to do a full and final rewrite of this project. I'm encountering issues that I do not understand and quite frankly it has been very frustrating. I feel so helpless not knowing why my code behaves the way it does. Things that used to work no longer do with little to no modification. And I don't know if it's because of mistakes I made as a programmer or something I don't know about the language/calculator. I really really wanted to create a good game but it feels like I've been fighting the language at each step.

7
Axe / Re: Converting from Prgm to App
« on: March 25, 2023, 09:41:08 pm »
Thanks for taking the time to look it over and reply. I tried inverting it and the issue still persisted. I'm not sure what the problem could be. Can you try compiling and running it when you get a chance? If possible, uncomment the first AddMob so that you can also test the AI to see how it behaves on your calc. I open a new Wabbit when I compile and test, so the RAM is always clear. Here's a screenshot showing what's happening with both the tilemap and the AI.

I don't know how to proceed with trying to fix it.

Also I can't take full credit for the tile code. It's mostly Runer's from his GRAYPKMN source that I modified and repurposed for monochrome. Took a while to read and understand haha. I'm also considering possibly using Fullrene or Crabcake if converting to an app is somehow impossible. I'll keep trying to debug this. Also if you're willing to help me learn and optimize my code maybe we can work together sometime. Thanks again.

8
Axe / Converting from Prgm to App
« on: March 23, 2023, 10:28:52 pm »
Way way late, but thanks to both E37 and Zeda I was able to implement a working A* Algorithm in my game. The source for the project is on Github here: https://github.com/kiloments/axe-rl
I've been pretty inconsistent in working on it, but recently I started back up again. I've reached the point where I need to make the program into an app. I thought it would be as simple as change from compiling to No Shell to Compiling as an Application, but once I did it looked like the my appvars were somehow being corrupted. When I moved around the map random tiles would get changed when I left an area and came back to it. The attached gif illustrates what I mean.

You can also see a little confused slime walking outside the map. This is because the DistMap appvar I'm using to calculate the AI is somehow also being corrupted. It's initially spawned in the room that gets corrupted then wanders its way out ignoring collision. I even compiled an older working version to verify and it seems to confirm. Everything works as a program and not as an App. I would like any help in beginning to convert this project into an app. And any other advice/optimizations you may have. Thanks!

9
Axe / Re: A* Star and Min Heap Help
« on: July 10, 2022, 11:28:53 am »
Yes that is correct. Not sure if the While loop condition is the problem or the Swap function.

10
Axe / A* Star and Min Heap Help
« on: July 10, 2022, 10:55:38 am »
I've been trying to implement an A* Star algorithm in Axe, but I've been encountering a whole host of bugs or things I can't explain. I need help so I'm hoping that @E37 reads this. It is in this code where I also get a few appvar bugs. Here is the whole AI code so far.
Code: [Select]
..AI
L2+00->->^^oDistMap
L2+02->->^^oTargetX
L2+04->->^^oTargetY
L2+06->->^^oStartX
L2+08->->^^oStartY
L2+10->->^^oCurrX
L2+12->->^^oCurrY
L2+14->->^^oHCost
L2+16->->^^oGCost
L2+18->->^^oSize
L2+20->->^^oMinIndex
L2+22->->^^oRoot
L2+24->->^^oRIndex
L2+26->->^^oMinHeap
Data(~1,1,~36,36)->^^oAIDir
Goto AIEND
Lbl DoMobAI
DrawGame()
For(M,0,Mobs-1)
^^oMobArray+(M*4)->Mob
CalculatePath(NewX,NewY,{^^oMobX+Mob},{^^oMobY+Mob})
End
Return
Lbl CalculatePath
GetCalc("appvDISTMAP")->DistMap
Fill(^^oTargetX,400,0)
~3->Size
Fill(DistMap,1296,|EFF)
[r1]->TargetX
[r2]->TargetY
[r3]->StartX
[r4]->StartY
Ge\tDistance(TargetX,TargetY,StartX,StartY)->HCost
GCost->{(TargetY-6)*36+(TargetX-6)+DistMap}
Insert(TargetX,TargetY)
While 1
Extract()->A
GCost++
0->J
For(4)
A+sign{^^oDir+J}->T
T^48->CurrX
T/48->CurrY
(CurrY-6)*36+(CurrX-6)->C
If ({T+Floor}<2)?({C+DistMap}=|EFF)
Ge\tDistance(CurrX,CurrY,StartX,StartY)->HCost
Insert(CurrX,CurrY)
GCost->{C+DistMap}
End
J++
End
EndIf ((CurrX=StartX)?(CurrY=StartY))
Return
Lbl Parent
Return ([r1]-3)/6
Lbl LeftChild
Return (6*[r1])+3
Lbl RightChild
Return (6*[r1])+6
Lbl ShiftUp
While ([r1]>>0)?({^^oMinHeap+Parent([r1])}>{^^oMinHeap+[r1]})
Swap(Parent([r1]),[r1])
Parent([r1])->[r1]
End
Return
Lbl ShiftDown
While 1
LeftChild([r1])->MinIndex+3->RIndex
If RIndex<<Size
If {^^oMinHeap+RIndex}<{^^oMinHeap+MinIndex}
RIndex->MinIndex
End
End
Swap([r1],MinIndex)
MinIndex->[r1]
EndIf (Size<<MinIndex)?({^^oMinHeap+MinIndex}>={^^oMinHeap+[r1]})
Return
Lbl Swap
{^^oMinHeap+[r1]}->[r3]
{^^oMinHeap+[r1]+1}^^r->[r4]
{^^oMinHeap+[r2]}->{^^oMinHeap+[r1]}
{^^oMinHeap+[r2]+1}^^r->{^^oMinHeap+[r1]+1}^^r
[r3]->{^^oMinHeap+[r2]}
[r4]->{^^oMinHeap+[r2]+1}^^r
Return
Lbl Insert
GCost+HCost->[r3]
([r2]*^^oFloorWidth+[r1])->{[r3]->{Size+3->Size+^^oMinHeap}+1}^^r
ShiftUp(Size)
Return
Lbl Extract
{^^oMinHeap+1}^^r->Root
{^^oMinHeap+Size}->{^^oMinHeap}
{^^oMinHeap+Size+1}^^r->{^^oMinHeap+1}^^r
Size-3->Size
ShiftDown(0)
Return Root
Lbl Ge\tDistance
abs([r1]-[r3])+abs([r2]-[r4])
Return
Lbl AIEND
First off, the appvar bugs that I have been getting. I am declaring the point for the DISTMAP appvar at the same time as the FLOOR appvar like so:
Code: [Select]
GetCalc("appvFLOOR",2304)->Floor
GetCalc("appvDISTMAP",1296)->DistMap
I'm only editing the floor appvar. I do not resize this in any way. If I do not call
Code: [Select]
GetCalc("appvDISTMAP")->DistMap again in CalculatePath(), then nothing will happen and the appvar doesn't get modified even though it exists. If I create the appvar in the AI code, then the pointers for the floor and the distmap somehow get mixed up and random garbage is scrolled in on the screen. The same thing happens if the distmap appvar already exists when I run the main program. However this only occurs for the distmap appvar as the floor appvar never has this issue. Also calling
Code: [Select]
DelVar "appvDISTMAP" does nothing. Not sure how this works. Please explain appvars to me like I'm 5 because something is not making sense.
Another bug I experience is using custom named variables to hold function labels. If that's not something that's possible please let me know. I know custom variables are 2 bytes and I am making sure of that so I don't know what is going on there. It only works with Alpha variables.
Back to the MinHeap, my ShiftUp function seems to do nothing. I don't know where the logic is failing. Each entry in the MinHeap is 3 bytes. The first byte is the F Cost of a given tile and the 2 bytes after that are the tile's offset. I'm trying to sort by F Cost, so that the lowest F Cost is the root of the MinHeap. Is the problem with my ShiftUp function or the Swap function? Please help! Thanks  :banghead:

11
Axe / Re: Axe Q&A
« on: July 10, 2022, 12:56:01 am »
Its more like a little note to the compiler that tells it to replace that named constant with the value you assigned it.

12
Axe / Re: Axe Q&A
« on: July 09, 2022, 10:11:48 pm »
You use the degree when you are first naming any constant. If you are going to use it as a variable elsewhere you no longer need the degree when using it. On the other hand, if you are using the named constant for its value, then you always need the degree.

13
Axe / Re: Axe Q&A
« on: July 09, 2022, 08:45:39 pm »
Hey there! If you are talking about custom named variables, what you can do is take a memory location and give it a name using the degree symbol like so:
Code: [Select]
L1+00->->°MyVarThen you can use it as a variable in any way like so:
Code: [Select]
42->MyVarAny custom variable you create will always be 2 bytes in size.
If you use this for any other value that is not a memory location, it is basically a named constant that you can use in place of that number. It serves no purpose outside of improving readability, but it is helpful.
When using named constants you must include the degree symbol. This is not the case when using a custom variable.
There are a few additional rules for naming anything in Axe. They must begin with a capital letter and they cannot be more than 13 characters long. They must also only contain letters or numbers. Hope this helps.

14
Axe / Re: Axe Q&A
« on: July 06, 2022, 02:22:00 am »
I'm starting to think that this is just an Axe bug. I'm never resizing or deleting or recreating, just editing them. I "fixed" the problem by calling GetCalc again before I manipulate the appvar. I have another issue. It seems that signed comparison or signed operations don't seem to work.
I have a line of code that looks like this:
Code: [Select]
~8->{°MobOX+Mob}Later on I call a function that looks like this:
Code: [Select]
Lbl AnimateMob
For(I,0,Mobs-1)
°MobArray+(I*4)->Mob
If {°MobOX+Mob}>>0
{°MobOX+Mob}--
End
If {°MobOX+Mob}<<0
{°MobOX+Mob}+1->{°MobOX+Mob}
End
If {°MobOY+Mob}>>0
{°MobOY+Mob}--
End
If {°MobOY+Mob}<<0
{°MobOY+Mob}+1->{°MobOY+Mob}
End
End
Return
However, despite being a signed comparison, it still treats {°MobOX+Mob} as some large number and decrements it instead. I've used the sign{} command but that only breaks it further. How do I do this? It's starting to feel like I really have to fight the language to do simple things. I've hand calculated the offsets so nothing is off there when I draw. It is literally not working with negative numbers. I've subtracted 8 instead, I've changed the comparison from signed to unsigned. I'm really at a loss here. Please help!

15
Axe / Re: Axe Q&A
« on: July 05, 2022, 12:15:56 am »
Does Axe not allow you to manipulate more than one appvar at a time? I'm getting some really strange bugs when I do. I have 2 appvars that I create in RAM. One is the appvar for the current generated floor in my game. The second appvar is supposed to be another map that I am going to use in my AI calculation that I call DistMap. I running across several strange bugs with Axe when I do this. If I create both appvars at the same time, I am no longer able to manipulate the DistMap appvar if I do anything with the Floor appvar. In this case all I am trying to do is fill it with some value for now. If I instead create the DistMap appvar whenever I press a button (down in this case), the tilemap gets corrupted somehow. Or rather, it seems as if the 2 pointers are getting mixed up somehow. Because when I try to move down a bunch of corrupted tiles are scrolled in instead. Any ideas?

Pages: [1] 2 3 ... 9