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.


Topics - LemonDrop

Pages: [1]
1
Axe / Tilemap dynamic lighting (fog of war) help
« on: November 15, 2013, 10:55:08 pm »
So I was trying to think of a system to do a sort of fog of war system based on tiles that can be seen by the player (not relatively complex), but was having a hard time doing so. The first idea I had involved having a sort of nested for loop x/y system which would check all the sprites in a diamond shaped area (in a certain order of course) and if it hit a solid tile, abort that row. Sadly mid-coding it I realized it would only work on one axis so I decided the only other way would be to do actual raycasting checks to see if anything is in the way of each "light beam" to a tile (in a diamond area pattern again). I planned it to go something like:

  • Index all (solid) tile coordinates (tile x*8, tile y*8) in a 7x7 area to some temp location. (Square because calculating a diamond is more costly)
  • For each tile in the view diamond loop, use the start and end point of the "line" made from the player to the tile to check if any of the x/y coordinates in the previous step are within 8 pixels of it. (Math behind it: http://stackoverflow.com/a/14554286/2085551)
  • Finally display the ones as they pass the test

As fast as axe is at math however I feel like this many calculations may slow down my frame times too much, so I was wondering if there's some crazy optimized calculator method of "dynamic lighting" or whatever for tile-based games.

2
Axe / Bullet trig questions
« on: November 03, 2013, 01:41:58 am »
So I have been trying to make a bullet movement system based off a concept like this:

(I am pretty sure this math is correct)

The inverse tangent function makes sense with how it returns a number between 0-255 but I don't really get how the sine and cosine ones work. They accept the same angle the arctan one outputs, but then they output a value between -127 to 127 which is odd. Like I guess that 127 is supposed to represent the value 1 and -127 as -1, but I don't know how I would make a conversion like that inside code.

Heres what I was working on:
(X and Y are firing coordinates and W and Z are the target coordinates (x and y respectively).
Code: [Select]
If getKey(27) and (R=0) and (B<10)
.MAKE NEW BULLET
22->R
B+1->B*6+50+L1->I
Y->{I}
X->{I-1}

.SET SIGNS / WIDTH / HEIGHT (1 being positive, 0 being negitive)
If Y>Z
0->{I-2}
Y-Z->J
Else
1->{I-2}
Z-Y->J
End

If X>W
0->{I-3}
X-W->K
Else
1->{I-3}
W-X->K
End
.ANGLE
tan^-1(K,J)->{I-4}
.VELOCITY
1->{I-5}
End

.BUL_PROCESS
For(I,1,B)
6*I+50+L1->J

.FIND NEW DISPLACEMENT VIA ANGLE/HYP (VELOCITY)
cos({J-4})/127*{J-5}->K .This is where I have no idea what I am doing
sin({J-4})/127*{J-5}->L

.UPDATE POSITION BASED ON SIGN
If {J-2}
K+{J}->{J}
Else
K-{J}->{J}
End

If {J-3}
L+{J-1}->{J-1}
Else
L-{J-1}->{J-1}
End

.REMOVE OUT OF BOUNDS
If ({J}=57) or ({J}=0) or ({J-1}=89) or ({J-1}=0)
Copy(6*B+50+L1,J,6)^^r
B--
I--
End
End

I know the problem lies somewhere with how I am using the sine and cosine functions (or atleast tried to), but I dont know how to fix it because theres no much documentation on stuff like this. Anyone see a way to fix this?

3
Axe / 8 Directional movement help
« on: November 01, 2013, 03:00:53 am »
So I got some code that allows the user to move around on the screen with 8 directions (holding down multiple buttons), but mapping sprites to that is something I am challenged with. For 4 directional movement, you can just have some sort of directional value and store the key pressed (or some sort of state value) to there, and multiply it by 8 to get an offset in a spritesheet. Problem with 8 directional is you can have a lot of key combos (even weird ones like all 4 at once). I thought of doing the same thing and just adding the directional values together to get the offsets but its kind of silly and it skips a whole sprite at the end (number 10):

1-d
2-l
3-d+l
4-r
5-d+r
6-l+r
7-u
8-u+d
9-u+l
11-u+r

I was wondering if anyone had a better system than this because its been annoying me for a bit. Thanks.

4
Axe / Problem with shooter code
« on: August 01, 2013, 01:51:47 pm »
So pretty much I was looking at the axe example of a space invaders clone thing and was trying to just get movement and bullets working by using the system they had, just to try to learn the language better. Oddly though even though the code is very close to the example mine crashes after like 3 seconds. Before then it works fine but then a bullet sprite appears in the bottom left corner for some reason. Heres the code that isnt working:

Code: [Select]
.TEST
[002442DBE7BD2400->Pic1
[0000183C3C240000->Pic2
DiagnosticOff
ClrDraw
DrawInv

44->X
54->Y
0->B->E->T
Repeat getKey(15)
sub(D
DispGraph
sub(D
If getKey(2) and (X!=1
X-1->X
End
If getKey(3) and (X!=87
X+1->X
End
If getKey(4) and (Y!=1
Y-1->Y
End
If getKey(1) and (Y!=55
Y+1->Y
End
If getKey(54) and (T=0
B+1->B*3+L1->I
0->{I-2}
X->{I-1}
Y->{I}
15->T
End
T=0+T-1->T

For(I,0,B
I*3+L1->J
{J-2}-1+{J}->{J}
If {J}=57 or ({J}=0
B*3+L1->K
Copy(J,K,3)^^r
B-1->B
End
End
End
ClrDraw
ClrHome
Return

Lbl D
Pt-Change(X,Y,Pic1
For(I,0,B
Pt-Change({I*3+L1-1},{I*3+L1},Pic2
End

And what happens when I try to do stuff:


Dunno if this is the right place to ask this but any help would be nice

5
TI Z80 / Pure Ti-Basic command line thingy
« on: July 09, 2013, 05:41:51 pm »
So recently I have been working on this pretty big project of mine and thought I'd just post it here because a lot of projects end up here eventually.
What makes it different is that most shells I see use lots of libraries/assembly programs to make the filesystem or string parsing easier, but to me I feel like that would be cheating in a way, which is why I am doing it purely in ti-basic. It also will be only one file (other than a 20 byte assembly program to enable lowercase text) instead of being split into a ton of peices and cluttering up the calculator.
So far only a few commands work (cd,dc,who,evl, and ext) but there will be more later.
Current stuffs:


-General Infos-
Filesystem:
Tape-style filesystem (file header, then content all in one big string)
-File Headers: 16 Tokens
-Dir Headers: 13 Tokens
Max 99 Files/99 Dirs/10 Users
999 tokens per file, 99 tokens for file/dir names

Filesystem Layout:
dev - Top dir, equivalent of C:\ in windows or / in linux.
dev/bin - System data (user file, environment vars, os config)
dev/usr - User folders go here on account creation, general storage
dev/msc - Programs go here (installed or otherwise)

Var Usage:
Str0 - HDD
Str1 - RAM
Str2 - Network Transfer
Str3 - Input Buffer
Str4 - Parsed Command
Str5 - Parsed Argument
I,J - General Looping
X,Y,Z - Optimization Vars

Current Commands:
cd - Change dir, operates like cd on any other command line except it can't parse paths yet (local folders only and ..)
dc - Dir contents, equivalent of ls on linux or dir on windows. Returns the format: [File/Dir Name|File/Dir:Permission Value]
who - Current user, equivalent of whoami on linux. Gets current uID from ram, parses usr.sd file, displays the login name.
evl - Evaluate, just passes stuff through the expr() command.
ext - Exit, cleans up everything (except hard drive is persistence is enabled in the config, not yet tho) and exits.

Future Plans:
File/Dir moving/deleting/editing
User creation/deletion, password hashing
File permissions based on users
Really basic interpreted coding language
Network connecting/disconnecting on specified port
File sending/receiving calculator to calculator
Remote shell possibly
Compression/Decompression for files
Installers for extra commands or something

If anyone has any comments or suggestions feel free to post them.

Pages: [1]