对不起,我是法国人,我的英语很差,我使用"Google Trad“来帮助我,如果我读起来很奇怪,我很抱歉。我创建了一个“盲测”类型的游戏,我从一个歌手那里请求了3个标题,所以我在Javascript中创建了一个包含歌手和标题的对象。
function Chanson(chanteur, titre1, titre2, titre3, titre4, titre5, titre6, titre7, titre8, titre9, titre10) {
this.chanteur = chanteur;
this.titre1 = titre1;
this.titre2 = titre2;
this.titre3 = titre3;
this.titre4 = titre4;
this.titre5 = titre5;
this.titre6 = titre6;
this.titre7 = titre7;
this.titre8 = titre8;
this.titre9 = titre9;
this.titre10 = titre10;
}然后我创作了一些歌手和歌曲。
let Sardou = new Chanson("Michel Sardou", "Les lacs du Connemara", "Je vais t'aimer", "La maladie d'amour", "En chantant", "Être une femme", "La java de Broadway", "Le rire du Sergent", "La France", "Je vole", "Afrique adieu")
let Goldman = new Chanson("Jean-Jacques Goldman", "Il suffira d'un signe", "Comme toi", "Envole-moi", "Au bout de mes rêves", "Je marche seul", "Il changeait la vie", "La vie par procuration", "A nos actes manqués", "Encore un matin", "Né en 17 a Leydenstadt")
let Dassin = new Chanson("Joe Dassin", "Les Champs-Elysées", "Et si tu n'existais pas", "L'été Indien", "Dans les yeux d'Émilie", "A toi", "Siffler sur la colline", "Le petit pain au chocolat", "Ca va pas changer le monde", "Salut les amoureux", "La fleur aux dents", "<img src='img/joedassin.jpg'>")
let Hallyday = new Chanson("Johnny Hallyday", "L'envie", "Allumer le feu", "Quelque chose de Tenessee", "Le pénitencier", "Diego libre dans sa tête", "Requiem pour un fou", "Je te promet", "Que je t'aime", "Gabrielle", "Vivre pour le meilleur")
let Indochine = new Chanson("Indochine", "J'ai demandé à la lune", "L'aventurier", "Trois nuits par semaine", "3e Sexe", "Tes yeux Noir", "Un été Français", "Nos célébrations", "Juste toi et moi", "Miss Paramount", "Les Tzars")
let Aznavour = new Chanson("Charles Aznavour", "La Bohème", "Emmenez-moi", "Hier encore", "J'me voyais déjà", "Mes emmerdes", "For me Formidable", "Les Comédiens", "Non je n'ai rien oublié", "La mamma", "Mourir d'aimer")然后我做了一张桌子。
const MesChansons = [Sardou, Goldman, Dassin, Hallyday, Indochine, Aznavour]然后我使用"Math Random“随机选择一个歌手。我把它们放在我的DOM里。
const ChansonHasard = MesChansons[Math.floor(Math.random() * MesChansons.length)];
document.getElementById("achanger").innerHTML = ChansonHasard.chanteur
document.querySelector("p.t1").innerHTML = ChansonHasard.titre1
document.querySelector("p.t2").innerHTML = ChansonHasard.titre2
document.querySelector("p.t3").innerHTML = ChansonHasard.titre3
document.querySelector("p.t4").innerHTML = ChansonHasard.titre4
document.querySelector("p.t5").innerHTML = ChansonHasard.titre5
document.querySelector("p.t6").innerHTML = ChansonHasard.titre6
document.querySelector("p.t7").innerHTML = ChansonHasard.titre7
document.querySelector("p.t8").innerHTML = ChansonHasard.titre8
document.querySelector("p.t9").innerHTML = ChansonHasard.titre9
document.querySelector("p.t10").innerHTML = ChansonHasard.titre10然后我用一张图片把它们藏起来,我创建了一个"Flip ()“来翻转和查看标题(有点像"Family Feud")我不能在玩的时候记住所有的位置,所以我希望有另一个”响应“页面。没有隐藏答案的图片的同一页。问题是我用的是“数学随机”,所以从一页到另一页我不会有相同的歌手。所以..。你有什么想法吗?再次感谢你阅读我的文章。
发布于 2021-11-18 20:47:57
下面是我的建议
将值保存在数据库中比保存在另一个网页中更干净/更安全。
因此,创建一个数据库,并在每次选择标题时将值输入其中,我希望这会有所帮助。
发布于 2021-11-18 22:05:14
Use url parameters to pass a seed。主页可以提供包括种子的链接。链接可以指向同一页,但可以是with url parameters。主机/来宾使用提供的种子或生成种子。这是一致的。
https://stackoverflow.com/questions/70026206
复制相似问题