Menu

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.

Show posts Menu

Messages - tokke

#1
Quote from: kanonet on 2012-May-14
Tip for shooting: if you use the Pythagorean theorem + my above shooting-"code" you can avoid using sin/cos.
Btw do you shot at a static point or a moving target? If you target is moving, will your bullet follow the target or keep flying in a straight line?

the sin/cos is actually pretty easy for me to program, I wrote it down on paper, explained it to a friend, made a quick code and it works pretty nice.

And about targets... don't know yet, wouldn't probably follow :p

but thanks for the help and for getting me all excited for programming again  =D
#2
I have a breakthrough.

I was playing a ludum dare game and there were objects shot at a random position. I downloaded the source code, and found the code to fire at the position of the mouse...
it works with cos,sin,tan. So going to try to write a small example (fire from center to mouse pos-game) and then try to implement it in the snake XD

snake shooter AW YEAH

The movement is almost solved (I think :) )
#3
Damn, you make me feel like a little boy, all excited to get on this ride.

Now I want to get to work, open my laptop and code all evening.

and to answer your question about the tail parts:

I store the position of the head in 2, 1 dimension array's, at tailx[0] and taily[0]
increase a variable "tail" to count the amounts of tail pieces.
And move the numbers through the array's:

Code (glbasic) Select


loop:
tailx[0]=headx
taily[0]=heady

i=1

WHILE i<tail
DRAWSPRITE 1,tailx[i],taily[i]
i=i+1
WEND



So yea, i can not move more or less than the dimension of the image.

But thanks to your code, I just had a mindblowing thought :D...
#4
Quote from: kanonet on 2012-May-08
Simple: dont move 10 pixels each frame, move 1-3 for slower and up to 10 for faster. Just try to play with this a bit.

well, there is my problem, the dimension of my sprite (placeholder) is 10x10. I had dificulty writing the code for the tail, also 10x10/part. So I found a way. But the moment I move more,or less than the dimension of the sprite, i get gaps, or overlay.


QuoteExactly.

Thank you :), should be easy actually
QuoteWait bullet? In snake? Darn i didnt play this game for many Years.^^

Not my idea  =D

Quote
But in general its like this:
Code (glbasic) Select
fire shot:
bulletx=x
bullety=y
x2=mouseposition
y2=mouseposition
each frame move bullet:
inc bulletx, sgn(x2-bulletx)
inc bullety, sgn(y2-bullety)
check if youre at your target:
if bulletx=x2 and bullety=y2 or hit_something_in_world() then BOOOOM()


I got that far, but as in your code, my bullet would travel in a diagonal line, until x or y = x2 or y2 and then a straight line up, down, left or right.


QuoteThis is just pseudo code of a general idea how you do things like this, but maybe it helps you. Of cause it can get improved very much, e.g. for better looking bullet fly etc..

apreciate the help, great community
#5
I just started with this and plan on expanding.

Some stuff already on paper (not code) now just need to "find" the code.

Some things are just not clear for me.

I'll just try to explain:
-The "head" of the snake is 10x10 pixels. So i move 10 pixels in all directions. So how do I control the speed wihtout limiting fps? (where can i find the pong example?).
-So instead of using sprcoll for the walls, i just make a 2 DIM array, and assign booleans like wall[0][0]=1 would be a wall on pixel 0,0 and i can test if the coords. of the snake head are within those boundries? That is what you were saying?
-You talk about mouse shooter. Any code example for mouse shooting? I know what has to be done? But can't seem to find the code for it. my problem: Player location = x,y and mouse location = x2,y2. How do I let my "bullet" travel in a straight line from x,y to x2,y2 and go past it? that is the code i can not find.

And as i said, images are just place holders :)

O and sorry for the worst english ever. Native dutch speaking
#6
Just starting with glbasic. made a little snake game. all placeholders graphics
http://dl.dropbox.com/u/28111609/snake.rar

I set the speed(dificulty) by changing the fps. any other way?

EDTI: O and i can't seem to work with sprcoll. It feels like it makes a box and i collide with it, even when there is no sprite to collide with. I managed to make it work. But horrible code.
#7
ok... nvm... suddenly it works. I think it knows i asked for help... I changed nothing.
sorry i didn't give enough info.

SOLVED on its own  :blink:
#8
I can't seem to get it to work. Installed java jdk, added JAVA_HOME to the variables. any chance on a detailed walkthrough to get it to work? Maybe a complete reinstall?