It's an interesting idea, i generally give coordinates 2 bytes, where the last 5 bits are used as a fraction. You could use the entire 2nd byte for the fraction, but i like having 256 tiles to work with (vs. 256 pixels) and being able to find the character's position in the map quickly by just reading the MSB. I guess the CSE has a larger screen, too, so you'll need to work with a larger area than i do.
It's essentially the same idea you've got, just instead of varying how often to update the Y coordinate, i update it every frame, but with a fraction. So if i add 32 (%00100000), that moves the character one pixel (the first five bits are fractions, changing them won't change the sprite's position). But if i add 16, it moves the character half a pixel (ie. it takes two frames to move the character one pixel). I might start the velocity at 80 (2.5 pixels per frame) with a gravity of 8 (ie. it would take 10 frames for the player to come to a complete stop, though the last few frames the sprite would update very slowly, giving it a nice arc). I'm not sure how sound the physics are, but it looks nice to me
Also, that wind idea is really interesting. It'd be cool to have gusts of wind pop up from time to time blowing you one way or another.
Your projects are all really inspiring, you never cease to amaze me!
I'd be interested to read how you handle 45 degree angles. Horizontal and vertical lines are just inverting the Y and X velocities respectively, 45 degree angles are a bit more complicated.
Wow, that looks amazing! It's beautiful! I imagine a mini-golf game has to have lots of interesting math to it. How do you handle edges that aren't vertical or horizontal?
I just forgot, then. Oh well. Thanks for clearing it up, though.
Also, if you really think it's worth the effort you could look for an online LateX editor. I found this: http://www.codecogs.com/latex/eqneditor.php which will let you do things like relatively easily.
How do you do acceleration? I've never bothered with sine/cosine tables, i generally just give it an initial value and subtract gravity from velocity. Those other modes look pretty wild, a mixture of the moving and disappearing platforms would be great!
It's a nice idea, but some of it isn't all that clear to me. The first sentence, for example, made absolutely no sense to me until i looked at the following explanation. What is a dependent/independent variable? And what is a piecewise function? Just a function divided up depending on what value x has? Thinking about it more your example makes sense now, though you say that f(x) = 0 when x = 0, i think that should be f(x) = 1. Also, you wrote "closer ans closer".
The rest is pretty straightforward to me.
Like AssemblyBandit, i'm well out of high school. I took AP Calc in high school but have long since forgotten it all. I'll keep reading on as calculus and physics were always really interesting to me, i just never stuck with them after dropping out of high school and it's all vanished.
Thanks for putting the lessons together, pimathbrainiac!
Ok, i'm having some computer issues but i'll think about it (as well as converting my code to bits ) while i try to fix things up. To follow back, you can just compare the bits to where you left off, for example if you've rotated to %10011001, you need to look for a 1, then two 0's, then two 1's, etc. I'll need to look at some more patterns but i believe you can move diagonally following a %10101010 pattern. You'd just rotate the pattern twice, since it's essentially two moves packed in one.
EDIT: So for diagonal movement, instead of checking bit 0 of the pattern, check bit 1. If bit 1 is correct, you can move diagonally.
Ok, i think i get it now. Thanks I just wrote a little program (see the screenshots). But i haven't switched over to using bits, i've got it all set up using one byte per tile per array (using bits has to be a pain, have you written it already?). I also couldn't think of a way to avoid checking bytes that were closed multiple times, so i changed their value to 2 once i processed them. I also ran into an issue with adding values to the closed array and processing them in the same iteration, so i ended up running through the the array first and storing the values (well, pushing them onto the stack) that i needed to process and then processing them afterwards.
Ok... so now that i've actually figured out (mostly) what it is you're talking about, what exactly is giving you trouble? Writing the backtracking portion? Or is that ok, just working with bits is complicating things?
end: bcall(_ClrLCDFull) di ld hl,b_tilemap ;x + y ld de,1+(6*WIDTH) ld bc,13+(5*WIDTH) add hl,de;starting position in map start: ld de,CLOSED add hl,de;b_closed ld (hl),1;starting position marked as ready to check add hl,de;b_nodes ld (hl),0;first node starts off at 0 ld hl,b_closed add hl,bc ld (hl),$FF ld bc,SIZE ex af,af' ld a,%00110011 ex af,af' ld hl,b_closed search_outer: push hl push bc ex af,af' push af call disp_frame pop af ex af,af' pop bc pop hl di ld de,0 search_loop: ld a,(hl) dec a jr nz,$+4 push hl inc e inc hl dec bc ld a,c or b jr nz,search_loop;check if bc = 0, repeat if no
retrieve_tiles: ld a,e or a jr z,+_ pop hl push de call expand_tile pop de dec e jr nz,retrieve_tiles _ld hl,b_closed;reset search values ld bc,SIZE ex af,af' rrca;rotate to next part of pattern ex af,af' jr search_outer
expand_tile: ;search_right inc (hl);set to 2 = closed inc hl ld a,(hl) inc a cp 2 call c,check_tile search_left: dec hl dec hl ld a,(hl) inc a cp 2 call c,check_tile search_down: inc hl ld de,WIDTH add hl,de ld a,(hl) inc a cp 2 call c,check_tile search_up: ld de,-WIDTH*2 add hl,de ld a,(hl) inc a cp 2 ret nc check_tile: ld de,CLOSED or a sbc hl,de;hl points to -b_tilemap- ld a,(hl) or a;check if current tile = 0 add hl,de;doesn't affect z, -b_closed- jr nz,$+4 ld (hl),1;1 = expand during next iteration cp 3 jr nz,$+4 ld (hl),'X'-'0' add hl,de;hl points to -b_node- ex af,af' ld b,a and %1 ld (hl),a;load the current pattern ld a,b ex af,af' sbc hl,de;restore hl ret
disp_frame: bcall(_HomeUp) display_smc = $+1 ld hl,b_tilemap ld bc,WIDTH*256+HEIGHT d_loop: push hl ld de,-b_tilemap add hl,de ld de,-SIZE add hl,de jr c,$-1 or a sbc hl,de ld de,b_tilemap add hl,de ld a,(hl) cp 1 pop hl ld a,(hl) jr nz,$+4 ld a,$E0-'0' add a,'0' bcall(_PutC) inc hl djnz d_loop ld de,(curRow) inc e ld d,0 ld (curRow),de ld b,WIDTH dec c jr nz,d_loop _call pause ld a,b dec a ld de,SIZE rra rra jr c,+_ ld hl,(display_smc) sbc hl,de ld (display_smc),hl jr disp_frame _rra ret c ld hl,(display_smc) add hl,de ld (display_smc),hl jr disp_frame
pause: call release_keys pause_loop: xor a call read_keys inc a jr z,pause_loop ld b,a release_keys: xor a call read_keys inc a jr nz,release_keys ret
;direct input read_keys: out (1),a; push af;short delay pop af in a,(1) ret
I'm trying to follow but i'm not entirely sure i get it. Rather than using full bytes you're storing 8 entries per byte, no? I'm not sure how you plan to store the direction (0-7), using nibbles/a full byte would take up a lot more room.
The implementation uses three bit-mapped 128 byte buffers to represent a 32x32 map. These buffers are contiguous in RAM. (listed in order) b_tilemap: each bit represents whether a tile is walkable or not. 0 = empty, 1 = wall. b_closed: each bit represents whether this node has been visited or not by the search algorithm
Quote
b_nodes: each bit represents the value assigned to the node when it was visited. This value is used for backtracking, and this is why the algorithm is interesting!
This is also the part i don't quite get. How do you determine which value to give it?
Quote
When the routine starts, the bit of the starting node in b_closed is set. Each iteration of the search passes over the entire buffer. Every bit in the b_closed buffer is "expanded" into each of the 4 adjacent bits that are not walls in b_tilemap.
So you essentially mark the starting location as closed, then what? Is everything (the four adjacent bits/tiles) marked as "visited"? I'm not sure how you keep track of where active paths are.
Quote
Any newly expanded bits that were not already set in the b_closed buffer are assigned a value of either 1 or 0 in the b_nodes buffer. This value is the same for every new bit expanded during the iteration. After each pass, the bit of the goal node is tested in b_closed. If it is set, we know the goal node has been visited, so we can now backtrack from here to the start by following our b_nodes values!
How do you determine whether it's a 1 or a 0?
Quote
The assigned b_nodes value follows the pattern 0, 1, 1, 0, 0, 1, 1, 0, etc, changing each iteration to the next value in the pattern. This is the key to this algorithm. At any given index in this pattern, the previous and next indices always have different values. With a reference of the current value and either the next value or the previous value in the pattern, the third value can always be determined
It sounds interesting, but i think an example would be really helpful to see what exactly's going on
For diagonal moves, would it not work just expanding the initial search to the 8 surrounding tiles (and checking the 8 surrounding tiles when tracing back)?
That's a great story about your math teacher! I wish more people would encourage people to explore, rather than limiting them to what something's "intended" use is. Congratulations to both you and your teacher
It looks great as usual, just one thing, in the screenshot i don't understand what that sentence means: "Because you accepted you got more money that if you kept going your points increased."
You mean just treat the text as a large sprite? I'm not sure what you mean in the second part, i figured Matrefeytontias was xor'ing a bar over top of them which can be done either way.
Another idea for the menu that might look alright is just putting the menu where the big "X" is, if it'll fit. And when you say 436 bytes (i'm not quite sure where you got that number from, unless you just made that number up. It's not even divisible by 8 ), i'd just like to ask how many bytes the sprites you use in the title screen take up
I don't think the menu's super important anyway, just so long as it works.