38 lines
1.2 KiB
Text
38 lines
1.2 KiB
Text
# state.ludic - the body, its camera, and the queue of what happened to it
|
|
const chr_pi: float = 3.14159265
|
|
|
|
|
|
|
|
|
|
|
|
# the camera: an orbit round a pivot at the chest, or the eyes
|
|
|
|
|
|
|
|
export function char_facts(character_st: CharacterState) -> Queue<CharacterFact> {
|
|
return character_st.chr_fact_q
|
|
}
|
|
|
|
# a fact record no drain holds any more, made fresh (and kept) only when every one is held: a
|
|
# fact can come every frame, and a record a frame is never given back
|
|
function chr_fact_record(character_st: mut CharacterState) -> CharacterFact {
|
|
if character_st.chr_fnext >= len(character_st.chr_ffree) {
|
|
q_unheld(char_facts(character_st), character_st.chr_fpool, character_st.chr_ffree)
|
|
character_st.chr_fnext = 0
|
|
}
|
|
if character_st.chr_fnext < len(character_st.chr_ffree) {
|
|
let f = character_st.chr_ffree[character_st.chr_fnext]
|
|
character_st.chr_fnext += 1
|
|
return f
|
|
}
|
|
return chr_fact_more(character_st)
|
|
}
|
|
function chr_say(character_st: mut CharacterState, what: int, v: float) -> void {
|
|
let f = chr_fact_record(character_st)
|
|
f.what = what
|
|
f.x = character_st.chr_x
|
|
f.y = character_st.chr_y
|
|
f.z = character_st.chr_z
|
|
f.v = v
|
|
q_push(char_facts(character_st), f)
|
|
}
|