Beiträge: 396
Themen: 8
Registriert seit: Sep 2013
Bewertung:
0
So what exactly do you want me to do?
Shall I do a full code cleanup with comments? You code is a bit unstructured and therefore hard to understand. I think the major problem is how you want to do the game logic.
BTW, you should give your sourcecode file a proper extentions, like .bb2, .ab2 or .ab3 (prefered if you use Amiblitz3).
Beiträge: 396
Themen: 8
Registriert seit: Sep 2013
Bewertung:
0
Well, there is nothing specific to point out. You need change the architecture and need more coding discipline to succeed.
Here are a few hints:
- use global variables only in the global context, don't import them to functions (=>"side effects", which create unnecessary complexity and cause slow and painful death to your project when it grows)
- don't use subroutines (Gosub), as they run in global context, use functions only
- a function should do one thing and should depend entirely on the parameters (ideally, the map/world may be an exception)
- use meaningful constants or better variables, no literals (99 = #ROBOT ?)
- use types for all variables, e.g. set "syntax 2" or "syntax 6" on top of the code, this will enforce you to declare types
For the architecture:
- drawing of static "objects" should be taken out of the game loop (this is why you use BBlit, otherwise, if you do full-frame refresh, you could use QBlit or just Blit as this is faster)
- the map should contain (semi-)static objects, the object list should contain moving objects
- don't use shapeshit for collision when you have animated objects. one frame might not collide and allow you to move, the next might collide because the sprite has changed, and you can get easily stuck. use rectangle hit strategy, this is sufficient for most cases. probably you don't even need to compare shapes as all your walls are 32x32, you can just check the map independently from its visualization.
question: do you want your player to move freely or in 32x32 grid?
try to make everything more object oriented, and make use of pointers, something like
[ab3]NEWTYPE.player_T
x.w
y.w
direction.w
...
End NEWTYPE
*player.player_T = player_New{initx.l,inity.l}
player_Draw{*player.player_T, bitmapID.l}
player_CanMove{*player.player_T, *map.map_T}
player_Move{*player.player_T, dx.l, dy.l}
player_Delete{*player.player_T}
*map.map_T = map_New{*data.l}
map_Draw{*map.map_T, bitmapID.l}[/ab3]
hope this helps.
Beiträge: 41
Themen: 12
Registriert seit: Oct 2013
Bewertung:
0
Yes! That is all the help I really want. I will not be able to learn if I do not make mistakes and fix them myself. If I rely on people to do all the work for me...then I have done nothing. I would rather crawl, stand up, walk, fall again, crawl, stand up, walk and fall again until I can run. So to answer your question, that is all I wanted. I just want to ask one question...if I get so seriously stuck could I ask you to help me on that part that I get stuck? But of course after putting 300% effort from my part to solve it!
What I will do now...is stop where I am...make a backup of this code...redo everything again and check mark all your helpful suggestion and tips into my code...and see how this works out. This project is more to teach me proper programming technique than the actual game it seems.
Ooh...I forgot to answer your question...I want the character to move in 32 grid and not freely. Also I do not want the character to movie diagonally...I want the character to move only in four directions: UP, DOWN, LEFT and RIGHT. I cannot move on in this game and add magnet, and screen scrolling, high score, etc without scrubbing everything I did so far and following your advice completely. THE PROJECT will end up hideously slow, buggy, frustrating to make, non-usable for further project and failure. IN FACT...I want to make my own tiny little INCLUDE where I have my own custom functions that can be used in future projects with ease. I want the main program to have so few lines of code...
I have much work than needs to be done. I think it is best I develop this or optimize the code in WinUAE because my Amiga 4000D running at just 040 @ 25 Mhz is too slow for AmiBlitz3....tooooooooooooooooooooooooooooooooooooooooooooooooooo slow and this is not something I want on my head as I program.