Skip to content

Commit

Permalink
#68, bottom text is now an image
Browse files Browse the repository at this point in the history
  • Loading branch information
James Touthang committed Dec 13, 2022
1 parent 67892b8 commit 700fa5a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions public/js/tasks/cooperation_task/cooperation_task.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ var resources = [
{ name: 'neutral_face', path: '/js/tasks/cooperation_task/media/neutral_face.png' },
{ name: 'coop_neut_sound.mp3', path: '/js/tasks/cooperation_task/media/coop_neut_sound.mp3' },
{ name: 'coop_pos_sound.mp3', path: '/js/tasks/cooperation_task/media/coop_pos_sound.mp3' },
{ name: 'scream.wav', path: '/js/tasks/cooperation_task/media/FearConditioning_media_Scream2sx3B.wav'}
{ name: 'scream.wav', path: '/js/tasks/cooperation_task/media/FearConditioning_media_Scream2sx3B.wav' },
{ name: 'pleasant_bottom_text', path: '/js/tasks/cooperation_task/media/pleasant_text_bottom.png' },
{ name: 'unpleasant_bottom_text', path: '/js/tasks/cooperation_task/media/unpleasant_text_bottom.png'},
]

// schedule the experiment:
Expand Down Expand Up @@ -585,15 +587,13 @@ function experimentInit() {
});

// Game Type Explanation
g.game_type_text_stim = new visual.TextStim({
win: psychoJS.window,
name: 'game_type explanation',
text: g.game_type_text['pleasant'],
font: 'Arial',
units: 'norm',
pos: [0, -0.8], height: 0.05, wrapWidth: 1.4, ori: 0,
color: new util.Color('white'), opacity: 1,
depth: 0.0
g.game_type_text_image_stim = new visual.ImageStim({
win : psychoJS.window,
name : 'bottom_text_image', units : 'height',
image : 'pleasant_bottom_text', mask : undefined,
ori : 0, pos: [0, -0.2], opacity : 1,
flipHoriz : false, flipVert : false,
texRes : 128, interpolate : true, depth : 0
});

endClock = new util.Clock();
Expand Down Expand Up @@ -1144,7 +1144,7 @@ function trialsLoopEnd() {

g.text_val_game_type.setAutoDraw(false); // Top right text

g.game_type_text_stim.setAutoDraw(false); // bottom text
g.game_type_text_image_stim.setAutoDraw(false) // bottom text

g.slideStim.setAutoDraw(false)

Expand Down Expand Up @@ -1297,15 +1297,33 @@ function blockRoutineBegin(block) {
// g.text_game_type.setAutoDraw(true)
if (game_type == 'pleasant') {
g.text_val_game_type.color = g.PLEASANT_COLOR;

g.text_val_game_type.setText('Positive Outcome Games')
g.game_type_text_image_stim = new visual.ImageStim({
win : psychoJS.window,
name : 'bottom_text_image', units : 'height',
image : 'pleasant_bottom_text', mask : undefined,
ori : 0, pos: [0, -0.35], opacity : 1, size: [1,0.13],
flipHoriz : false, flipVert : false,
texRes : 128, interpolate : true, depth : 0
});
} else {
g.text_val_game_type.color = g.UNPLEASANT_COLOR;
g.text_val_game_type.setText('Negative Outcome Games')

g.game_type_text_image_stim = new visual.ImageStim({
win : psychoJS.window,
name : 'bottom_text_image', units : 'height',
image : 'unpleasant_bottom_text', mask : undefined,
ori : 0, pos: [0, -0.35], opacity : 1, size: [1,0.13],
flipHoriz : false, flipVert : false,
texRes : 128, interpolate : true, depth : 0
});
}
g.text_val_game_type.setAutoDraw(true)

g.game_type_text_stim.setText(g.game_type_text[game_type])
g.game_type_text_stim.setAutoDraw(true);

g.game_type_text_image_stim.setAutoDraw(true);

// g.rect[1].setAutoDraw(true)
// g.rect[2].setAutoDraw(true)
Expand Down Expand Up @@ -1388,7 +1406,8 @@ g.choice_counter = {
* Increment the outcome counter after it's been used.
* @param {*} outcome_type either a positve or negative outcome type
*/
function incrementCounters(outcome_type){
function incrementCounters(outcome_type) {
// console.log('increment (pre): ',outcome_type,g.choice_counter['positive'], g.choice_counter['negative'] )
switch (outcome_type) {
case 'positive':
g.choice_counter['positive']++
Expand All @@ -1405,13 +1424,15 @@ function incrementCounters(outcome_type){
}
break;
}
// console.log('increment (post): ',outcome_type,g.choice_counter['positive'], g.choice_counter['negative'] )
}

/**
* Returns either positive or negative given random probability
* @param {*} probability probabilty
*/
function getRandomOutcome(probability, game_type) {
console.log('get random: ', game_type, probability )
if (Math.random() < probability) {
// returns the game_type. Either 'plesant' or 'unpleasant'
return (game_type == 'pleasant' ? 'positive': 'negative');
Expand All @@ -1428,7 +1449,6 @@ function getRandomOutcome(probability, game_type) {
function getOutcomePair(outcome, game_type, choice) {
switch (outcome) {
case 'neutral':
// returns outcome_triple based on game_type
if (game_type == 'pleasant') {
g.outcome_triple = g.outcome_media.positive[g.choice_counter['positive']];
incrementCounters('positive')
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 700fa5a

Please sign in to comment.