Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

finished animation texture handling for the player

  • Loading branch information...
commit e15ef19f5845f6ac7d24c8cda47c2d1e792aa096 1 parent abb716d
@Karlinde Karlinde authored
Showing with 77 additions and 23 deletions.
  1. +1 −0  .gitignore
  2. +75 −22 Player.rkt
  3. +1 −1  setuptextures.rkt
View
1  .gitignore
@@ -0,0 +1 @@
+*.bak
View
97 Player.rkt
@@ -34,14 +34,15 @@
((down) 180)))
(gait-state #t)
(animation-state (case dir
- ((left) 0)
- ((up) 1)
- ((right) 2)
- ((down) 3)))
+ ((left) 0)
+ ((up) 1)
+ ((right) 2)
+ ((down) 3)))
(transitstate 0)
(targetx xpos)
(targety ypos)
- (in-transit #f))
+ (in-transit #f)
+ (moved-last-tick #f))
;-----------------------------------------------------------------------------------
;sets the direction of the player to new-dir
@@ -154,7 +155,14 @@
(down 3)
(space 4)
(facing dir))
- (when (not in-transit)
+ (unless in-transit
+ (if moved-last-tick
+ (set! moved-last-tick #f)
+ (set! animation-state (case dir
+ ((up) 0)
+ ((right) 1)
+ ((down) 2)
+ ((left) 3))))
(cond ((and (vector-ref keys left)
(not (vector-ref keys right))
(not (vector-ref keys up))
@@ -204,29 +212,74 @@
(vector-ref keys down))
(eq? dir facing))
(set! in-transit #t)
+ (set! gait-state #t)
(case dir
((up) (set! animation-state 4))
((right) (set! animation-state 8))
((down) (set! animation-state 12))
((left) (set! animation-state 16)))))
(when in-transit
- (when (eq? (remainder ticks speed) 0)
- (if gait-state
- (case animation-state
- ((4) (set! animation-state 5))
- ((5) (set! animation-state 6))
- ((6) (set! animation-state 7)
- (set! gait-state #f)))
- (case animation-state
- ((7) (set! animation-state 6))
- ((5) (set! animation-state 4)
- (set! gait-state #t))
- ((6) (set! animation-state 5)))))
+ (if moved-last-tick
+ (begin
+ (display gait-state)
+ (display " ")
+ (display animation-state)
+ (newline)
+ (case dir
+ ((up down)
+ (when (eq? (remainder ypos 16) 0)
+ (if gait-state
+ (case animation-state
+ ((4) (set! animation-state 5))
+ ((5) (set! animation-state 6))
+ ((6) (set! animation-state 7)
+ (set! gait-state #f))
+
+ ((12) (set! animation-state 13))
+ ((13) (set! animation-state 14))
+ ((14) (set! animation-state 15)
+ (set! gait-state #f)))
+ (case animation-state
+ ((7) (set! animation-state 6))
+ ((5) (set! animation-state 4)
+ (set! gait-state #t))
+ ((6) (set! animation-state 5))
+
+ ((15) (set! animation-state 14))
+ ((13) (set! animation-state 12)
+ (set! gait-state #t))
+ ((14) (set! animation-state 13))))))
+ ((left right)
+ (when (eq? (remainder xpos 16) 0)
+ (if gait-state
+ (case animation-state
+ ((8) (set! animation-state 9))
+ ((9) (set! animation-state 10))
+ ((10) (set! animation-state 11)
+ (set! gait-state #f))
+
+ ((16) (set! animation-state 17))
+ ((17) (set! animation-state 18))
+ ((18) (set! animation-state 19)
+ (set! gait-state #f)))
+ (case animation-state
+ ((11) (set! animation-state 10))
+ ((9) (set! animation-state 8)
+ (set! gait-state #t))
+ ((10) (set! animation-state 9))
+
+ ((19) (set! animation-state 18))
+ ((17) (set! animation-state 16)
+ (set! gait-state #t))
+ ((18) (set! animation-state 17))))))))
-
-
-
- (move! dir ticks)))
+ (set! moved-last-tick #t))
+
+
+
+
+
+ (move! dir ticks)))
;-------- Check the tile triggers ------
(let ((tile (send (get-field current-map world) gettile gridx gridy)))
View
2  setuptextures.rkt
@@ -110,7 +110,7 @@
(set! j (+ j 1)))
char-list)
(begin
- (glBindTexture GL_TEXTURE_2D (gl-vector-ref char-texture-list (* i 16)))
+ (glBindTexture GL_TEXTURE_2D (gl-vector-ref char-texture-list (* i 20)))
(glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER GL_LINEAR)
(glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER GL_LINEAR)
(glTexImage2D GL_TEXTURE_2D
Please sign in to comment.
Something went wrong with that request. Please try again.